Can we define min-margin and max-margin, max-padding and min-padding in css?

后端 未结 19 1527
情话喂你
情话喂你 2021-01-31 01:01

Can we define min-margin and max-margin, max-padding and min-padding in CSS ?

19条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-31 01:39

    Late to the party, but I'd like to share my simple solution. I'm gonna assume that if we want something that would work like a min-margin, it's because we have a margin: auto; in the first place, and we don't want that margin auto being smaller than a certain number.

    We can do that with two div, one inside another.

    Here is an example with horizontal margins.

    Lorem Ipsum etc

    As for the css:

    .margin-auto {
      margin: 0 auto;
    }
    
    .min-margin {
      margin: 0 16px;
      max-width: 300px;
    }
    

提交回复
热议问题