Skip to content

Instantly share code, notes, and snippets.

@juliankrispel
Created January 17, 2013 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juliankrispel/4557898 to your computer and use it in GitHub Desktop.
Save juliankrispel/4557898 to your computer and use it in GitHub Desktop.
Sass Loop for generating generic helpers
$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