Skip to content

Instantly share code, notes, and snippets.

@rebotak
Forked from victorS7P/spacers.scss
Created March 3, 2021 02:41
Show Gist options
  • Save rebotak/7d02bcc2ff9c1cfc2433d800e920b70d to your computer and use it in GitHub Desktop.
Save rebotak/7d02bcc2ff9c1cfc2433d800e920b70d to your computer and use it in GitHub Desktop.
padding and margin bootstrap based helpers
$positions: (
t: ('top'),
r: ('right'),
b: ('bottom'),
l: ('left'),
x: ('left', 'right'),
y: ('top', 'bottom')
);
@mixin sizeValue($prop, $i) {
#{$prop}: ($i * .5em);
};
@for $i from 0 to 6 {
@each $prop, $propValue in (m: 'margin', p: 'padding') {
.#{$prop}-#{$i} {
@include sizeValue((#{$propValue}), $i);
}
@each $var, $value in $positions {
.#{$prop}#{$var}-#{$i} {
@each $pos in $value {
@include sizeValue((#{$propValue}-#{$pos}), $i);
}
}
@if ($i == 0 and $prop == 'm') {
.m#{$var}-auto {
@each $pos in $value {
margin-#{$pos}: auto;
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment