【发布时间】:2017-06-14 21:30:38
【问题描述】:
除了已经建立的选择器之外,我想使用 mixin 让我可以根据需要将其他选择器作为参数传递。但我在这里遇到了一个错误。不知道我错过了什么,除非你不能在循环中使用变量而不将值传递给每个项目,而我将这一切都错了。
@mixin light-section-text( $selectors: null ) {
@if ( $selectors ) {
@for $i from 1 through length( $selectors ) {
#{nth( $selectors, $i )},
}
}
p,
address,
li {
color: $white;
}
}
在这种情况下,@include light-section-text( "body", "strong", "strong a" ); 的期望输出将是:
body,
strong,
strong a,
p,
address,
li {
color: #fff; }
【问题讨论】: