I'm kind of new in sass, and as I'm practicing it I've encountered this situation.
How can I achieve list of margin-top, margin-right, margin-bottom and margin-left, with different value offsets(I know this may sound unclear).
So here is the output(supposed to be) of the generated .css file by .scss
.offset-top-1{
margin-top: 1rem;
}
.offset-top-2{
margin-top: 2rem;
}
.offset-top-3{
margin-top: 3rem;
}
//.... so on to .offset-top-6 and also for .offset-right-x, .offset-bottom-x, and .offset-left-x
And here is my .scss file
@mixin offset-margin($margins){
margin: $margins;
}
@for $i from 1 through 20 {
.offset-top-#{$i}{
@include offset-margin(1rem * $i 0rem 0rem 0rem); // the other offset values should be removed since I'm dealing only for margin-top
}
.offset-right-#{$i}{
@include offset-margin( 0rem 1rem * $i 0rem 0rem);
}
.offset-bottom-#{$i}{
@include offset-margin(0rem 0rem 1rem * $i 0rem);
}
.offset-left-#{$i}{
@include offset-margin( 0rem 0rem 0rem 1rem * $i);
}
}
EDIT:
the @mixin directive offset-margin only allows "margin" though, what I wanted to achieve is to have specific margin location e.g margin-right, margin-left, etc.