Last active
September 6, 2016 14:57
-
-
Save kalpesh-fulpagare/c4425823872c110153f95ea4a35b078c to your computer and use it in GitHub Desktop.
Mixin for Generaing CSS classes for margin and padding.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Generate Margin/Padding Classes | |
* margin, margin-top, margin-bottom, margin-left, margin-right | |
* padding, padding-top, padding-bottom, padding-left, padding-right | |
*/ | |
@mixin margin-padding($min, $max, $css-property, $klass, $csspx: $min) { | |
@while $min <= $max { | |
@if $min != 0 { | |
$csspx: $min+px; | |
} | |
.#{$klass}-#{$min} { | |
#{$css-property}: $csspx !important; | |
} | |
.#{$klass}-t-#{$min} { | |
#{$css-property}-top: $csspx !important; | |
} | |
.#{$klass}-b-#{$min} { | |
#{$css-property}-bottom: $csspx !important; | |
} | |
.#{$klass}-l-#{$min} { | |
#{$css-property}-left: $csspx !important; | |
} | |
.#{$klass}-r-#{$min} { | |
#{$css-property}-right: $csspx !important; | |
} | |
$min: $min + 5; | |
} | |
} | |
@include margin-padding(0, 40, margin, m); | |
@include margin-padding(0, 40, padding, p); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment