我正在尝试写这样的东西:
@mixin variableChild($child:".theChild") {
//some css
$child {
//css specific to the child
}
}
#parent { @include variableChild(".specificChild"); };
Run Code Online (Sandbox Code Playgroud)
所以它会生成这个 CSS :
#parent {//some css}
#parent .specificChild {
//css specific to the child
}
Run Code Online (Sandbox Code Playgroud)
你几乎是对的,#{}我认为你只是错过了你的孩子选择器。在Sass 文档中有更多关于它的信息。
@mixin variableChild($child:".theChild") {
#{$child} {
color: red;
}
}
#parent {
@include variableChild(".specificChild");
};
Run Code Online (Sandbox Code Playgroud)