I have been working with SASS for sometime now. Today I came across an interesting issue where i had to style individual elements that had specific styles attached to it.
awesomeproduct, Tell me about it!
I have been working with SASS for sometime now. Today I came across an interesting issue where i had to style individual elements that had specific styles attached to it.
awesomeproduct, Tell me about it!
So I wrote a mixin as below:
@mixin generateClassNamesWithVariables($start,$stop, $classname, $css-element, $spacer){ @for $i from $start through $stop { .#{$classname}#{$i*$spacer} { #{$css-element}: #{$i * $spacer}px; } } }
This is how i have used the above mixin:
@include generateClassNamesWithVariables(1,5,margin-,margin,10); @include generateClassNamesWithVariables(1,5,margin-top-,margin-top,10); @include generateClassNamesWithVariables(1,5,margin-bottom-,margin-bottom,10); @include generateClassNamesWithVariables(1,5,pad-right-,padding-right,10); @include generateClassNamesWithVariables(1,5,pad-left-,padding-left,10); @include generateClassNamesWithVariables(1,5,pad-top-,padding-top,5); @include generateClassNamesWithVariables(1,5,pad-bottom-,padding-bottom,5); @include generateClassNamesWithVariables(1,5,pad-,padding,10); @include generateClassNamesWithVariables(10,30,f,font-size,1);
So what this mixin will do is generate the following css.
Now the html will be something like this, it is much cleaner and works like a charm!
Anawesomeproduct
good post mate, keep it up…chuur…
Hello there, I found your blog via Google at the same time as looking for a related topic, your website came up, it appears great. I’ve bookmarked it in my google bookmarks.
What’s up to every single one, it’s in fact
a nice for me to pay a quick visit this web page, it consists of important Information.
An intriguing discussion may be worth comment. I think that
you need to write a little more about this issue.