Skip to content

Instantly share code, notes, and snippets.

@bert-w
Last active June 30, 2017 13:07
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 bert-w/7736acfd2805aa30b78f848ff9a86294 to your computer and use it in GitHub Desktop.
Save bert-w/7736acfd2805aa30b78f848ff9a86294 to your computer and use it in GitHub Desktop.
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