Skip to content

Instantly share code, notes, and snippets.

@victorS7P
Last active March 3, 2021 02:41
Show Gist options
  • Save victorS7P/90d6edb245d1ce4f52c2173e3ccca6ae to your computer and use it in GitHub Desktop.
Save victorS7P/90d6edb245d1ce4f52c2173e3ccca6ae 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