Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@enricodeleo
Last active November 17, 2017 21:06
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save enricodeleo/181e96df28588b0f9d5f to your computer and use it in GitHub Desktop.
Save enricodeleo/181e96df28588b0f9d5f to your computer and use it in GitHub Desktop.
Loop that generates margin and padding class helpers
// loop that generates margin ad padding helper classes
// the output is like .margin-5, .margin-top-5, margin-right-5 etc...
$properties: (margin, padding);
$sides: (top, right, bottom, left);
@each $prop in $properties {
@for $i from 1 through 14 {
.#{$prop}-#{$i*5} {
#{$prop}: #{$i*5}px !important;
}
@each $side in $sides {
.#{$prop}-#{$side}-#{$i*5} {
#{$prop}-#{$side}: #{$i*5}px !important;
}
}
}
}
// the output is like .no-margin, .no-padding-top etc...
@each $prop in $properties {
.no-#{$prop} {
#{$prop}: 0 !important;
}
@each $side in $sides {
.no-#{$prop}-#{$side} {
#{$prop}-#{$side}: 0 !important;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment