SASS可以合并属性吗?
也许更好的问题是,有没有更有效的方法覆盖mixin的某些部分 这张SCS:SASS可以合并属性吗?,sass,Sass,也许更好的问题是,有没有更有效的方法覆盖mixin的某些部分 这张SCS: @mixin button { .button { background-color: red; color: white; } } .container { @include button; .button { background-color: green; } } 汇编至: .container .button { background-color: red;
@mixin button {
.button {
background-color: red;
color: white;
}
}
.container {
@include button;
.button {
background-color: green;
}
}
汇编至:
.container .button {
background-color: red;
color: white;
}
.container .button {
background-color: green;
}
我希望它能编译成:
.container .button {
background-color: green;
color: white;
}
将参数传递到mixin:
@mixin button($color: red) {
background-color: $color;
color: white;
}
.container {
.button {
@include button(green);
}
}
我的mixin实际上比这里的示例复杂得多。我添加了更多的覆盖,而不仅仅是一个颜色更改。因此,从这个角度来看,添加参数将使事情变得太困难。如果存在某种@mergeproperties{}函数,那就太好了。