Skip to content

Instantly share code, notes, and snippets.

@bert-w
Last active Jun 30, 2017
Embed
What would you like to do?
SCSS/SASS helpers for padding & margin classes
$type: (p:padding, m:margin);
$position: (t:top, l:left, b:bottom, r:right);
$range: 0 5 10 15 20 25 30 35 40;
/*
* Loop and create classes that serve as quick padding/margin modifiers.
* Explanation of class syntax:
*
* ".p-t-0" Assign a padding-top of 0px (!important).
* ".m-b-35" Assign a margin-bottom of 35px (!important).
*
* Classes are generated for "p" (padding), "m" (margin), "t"/"l"/"b"/"r" (top/left/bottom/right), having a range of
* 0 to 40 (increments of 5).
*/
@each $t, $t2 in $type {
@each $p, $p2 in $position {
@each $r in $range {
.#{$t}-#{$p}-#{$r} {
#{$t2}-#{$p2}: #{$r}px !important;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment