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

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

    I wrote a library to do this, you can view it here: https://codepen.io/nicetransition/pen/OyRwKq

    to use in your case:

    .selector {
        scale($context, $base-size, $limit-size-min, $limit-size-max, $property: padding-right);
        scale($context, $base-size, $limit-size-min, $limit-size-max, $property: padding-left);
    }
    
    • $context: Max-width of your container

    • $base-size: Root font size

    • $limit-size-min: The minimum size

    • $limit-size-max: The maximum size

      .selector { scale(1400px, 16px, 5px, 20px, $property: padding-right); scale(1400px, 16px, 5px, 20px, $property: padding-left); }

    This would scale down to 5px and up to 20px, between 5-20 it is dynamic based of vw

提交回复
热议问题