Skip to content

Instantly share code, notes, and snippets.

@brittonwalker
Last active October 25, 2019 22:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save brittonwalker/d180f29462f52f5f3e5196bd6b27a1ed to your computer and use it in GitHub Desktop.
Save brittonwalker/d180f29462f52f5f3e5196bd6b27a1ed to your computer and use it in GitHub Desktop.
//
// Resposive spacer classes
// --------------------------------------------------
// Margin properties to cycle through
$margin-properties: (
mt: margin-top,
mb: margin-bottom,
my: margin,
ml: margin-left,
mr: margin-right
);
$padding-properties: (
pt: padding-top,
pb: padding-bottom,
py: padding,
pl: padding-left,
pr: padding-right
);
// Base number to multiply cycle length iterator
$base: 5;
// Cycle Length
$times: 60;
@each $name,
$number in $grid-breakpoints {
@media (min-width: $number) {
@each $prop-name,
$prop-val in $margin-properties {
@for $i from 0 through $times {
$value: $i * $base + 0px;
.#{$prop-name}-#{$name}-#{$i} {
@if $prop-name==my {
#{$prop-val}: $value 0px;
}
@else {
#{$prop-val}: $value;
}
}
}
}
@each $prop-name,
$prop-val in $padding-properties {
@for $i from 0 through $times {
$value: $i * $base + 0px;
.#{$prop-name}-#{$name}-#{$i} {
@if $prop-name==py {
#{$prop-val}: $value 0px;
}
@else {
#{$prop-val}: $value;
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment