开发者

How can I access variables which defined in my view code in Sass file?

开发者 https://www.devze.com 2023-03-06 18:28 出处:网络
I want to write some code in my rails v开发者_运维百科iew page to define a class with param for a div, which is like:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消