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

后端 未结 19 1747
情话喂你
情话喂你 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:56

    I was looking for a solution to make the contents of a row behave like in a fixed width container, but with shrinking browser width make a minimal margin from the left (in my case: so that the row contents do not hide under a big logo with position: absolute in left-top).

    This is what worked for me:

    HTML

    Some header

    CSS

    .parent-container {
      padding-left: min(150px);
    }
    .child-container {
      padding-left: calc( 50vw - 500px );
    }
    

    When I scale the browser window left and right, my h1 doesn't go to the left more than the 150px, but goes right following the behavior of my next row's content set to display in a fixed container.

提交回复
热议问题