Created
January 17, 2013 17:45
-
-
Save juliankrispel/4557898 to your computer and use it in GitHub Desktop.
Sass Loop for generating generic helpers
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
$x: 2; | |
$classnames: m, p; | |
$rulenames: margin, padding; | |
@while $x > 0{ | |
$classname: nth($classnames, $x); | |
$rulename: nth($rulenames, $x); | |
$i: 4; | |
$a: (-top, -right, -bottom, -left); | |
$b: (-t, -r, -b, -l); | |
@while $i > 0{ | |
$c: nth($b, $i); | |
$d: nth($a, $i); | |
.#{$classname} { | |
#{$rulename}: $margin; | |
} | |
.#{$classname}-s { | |
#{$rulename}: $marginSmall; | |
} | |
.#{$classname}#{$c}-l { | |
#{$rulename}#{$d}: $marginLarge; | |
} | |
.#{$classname}#{$c} { | |
#{$rulename}#{$d}: $margin; | |
} | |
.#{$classname}#{$c}-s { | |
#{$rulename}#{$d}: $marginSmall; | |
} | |
$i: $i - 1; | |
} | |
$x: $x - 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment