Scss混合函数变量作用域 不是舒尔,如果这是一个范围问题,请考虑以下内容: $custom : #f20; @mixin colorbyclass($class) { .#{$class} { background: $class; } } //scss @include colorbyclass(custom); //compiles .custom { color:custom; }
我的问题是,我希望$class作为函数内变量的引用。Scss混合函数变量作用域 不是舒尔,如果这是一个范围问题,请考虑以下内容: $custom : #f20; @mixin colorbyclass($class) { .#{$class} { background: $class; } } //scss @include colorbyclass(custom); //compiles .custom { color:custom; },css,compass-sass,sass,Css,Compass Sass,Sass,我的问题是,我希望$class作为函数内变量的引用。 我正在寻找其他解决方案的建议。我认为您不能在sass中使用变量。另一个问题似乎回答了您的问题:我认为您不能在sass中使用变量。另一个问题似乎回答了您的问题:变量在Sass中不存在。对于所呈现的mixin,您可以向其传递包含2个值的单个列表,也可以传递2个值 选项1: 选项2: 不过,它们看起来就像根本不使用mixin一样冗长: .container { div { width:20px; height:20px;
我正在寻找其他解决方案的建议。我认为您不能在sass中使用变量。另一个问题似乎回答了您的问题:我认为您不能在sass中使用变量。另一个问题似乎回答了您的问题:变量在Sass中不存在。对于所呈现的mixin,您可以向其传递包含2个值的单个列表,也可以传递2个值 选项1: 选项2: 不过,它们看起来就像根本不使用mixin一样冗长:
.container {
div {
width:20px;
height:20px;
&.custom {
background: $custom; // could easily be replaced with a mixin that sets a bg color + other stuff
}
}
}
Sass中不存在变量。对于所呈现的mixin,您可以向其传递包含2个值的单个列表,也可以传递2个值 选项1: 选项2: 不过,它们看起来就像根本不使用mixin一样冗长:
.container {
div {
width:20px;
height:20px;
&.custom {
background: $custom; // could easily be replaced with a mixin that sets a bg color + other stuff
}
}
}
我回到了原来的解决方案,和你上次的建议一模一样。谢谢。我回到了原来的解决方案,和你上次的建议一模一样。谢谢
.container {
div {
width:20px;
height:20px;
&.custom {
background: $custom; // could easily be replaced with a mixin that sets a bg color + other stuff
}
}
}