Sass 为转换插入和添加百分比:属性值无效
我尝试插值一个值并将其添加到一个转换字符串中,如下所示:Sass 为转换插入和添加百分比:属性值无效,sass,Sass,我尝试插值一个值并将其添加到一个转换字符串中,如下所示: @for $x from 1 through 30 { @for $y from 1 through 30 { $xt: calc(#{$x} * 100%); $yt: calc(#{$y} * 100%); .stone-0#{$x}0#{$y} { transform: translate(#{$xt}, -#{$yt}); } } } 但我得
@for $x from 1 through 30 {
@for $y from 1 through 30 {
$xt: calc(#{$x} * 100%);
$yt: calc(#{$y} * 100%);
.stone-0#{$x}0#{$y} {
transform: translate(#{$xt}, -#{$yt});
}
}
}
但我得到的结果是:
.stone-0204 {
transform: translate(calc(2 * 100%), -calc(4 * 100%));
}
如何获得输出:
.stone-0204 {
transform: translate(200%, -400%);
}
解决方法:
.stone-0#{$x}0#{$y} {
transform: translate(percentage($x), -#{percentage($y)});
}