SASS是否支持在混入中的所有属性中添加!important? [英] Does SASS support adding !important to all properties in a mixin?
本文介绍了SASS是否支持在混入中的所有属性中添加!important?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在使用指南针框架及其所有有用的CSS3 mixins。我想使用 border-radius(5px)
mixin并将所有来自它的属性标记为!important
I am currently using the compass framework and all it's helpful CSS3 mixins. I would like to use the border-radius(5px)
mixin and have all properties that come from it marked with !important
在不用中,可以申请!重要
通过在调用后简单地指定它即可在mixin中的所有属性
In LESS it is possible to apply !important
to all properties in a mixin by simply specifying it after call
.myMixin(@x) {
border-radius: @x;
-moz-border-radius: @x;
}
.myClass {
.myMixin(5px) !important;
}
编译为
.myClass {
border-radius: 5px !important;
-moz-border-radius: 5px !important;
}
在 SASS ,还是我必须重写具有重要参数的mixins?
Is this possible in SASS, or will I have to rewrite the mixins with an important parameter?
@mixin my-border-radius($value, $important: false) {
border-radius: @value if($important, !important, null);
....
}
推荐答案
答案几乎太明显了……
!important
可以简单地指定为属性的一部分值
!important
can simply be specified as part of the property value
border-radius(5px !important);
这篇关于SASS是否支持在混入中的所有属性中添加!important?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文