I want to write some code in my rails v开发者_运维百科iew page to define a class with param for a div, which is like:
%div{:class => div_with_width("500px")}
then in sass file, define a class mixin like:
=div_with_width(!width)
div
:width = !width
Can I write such code? Or is there a good way to do this? Thanks.
I think, by definition mixins are intended to be used in other SASS files. You may have to simply use the mixin in another SASS file, applying it to a real class. As SASS files are compiled to CSS if you don't go this route you may never see the mixin used and thus not defined at all in your final CSS output.
精彩评论