我想在sass中动态地构建一个转换语句(作为mixin参数),我不确定如何强制括号。
$dir: translateY;
$val: 42;
$i: 3;
.test {
transform: #{$dir}(#{$val * $i}) scale(1);
}
应该转换成
.test {
transform: translateY(126) scale(1);
}
它确实在libsass下这样做,但不幸的是我不能在这个项目中使用它。另一方面,我可以使用@if
语句,但感觉不一样。
你需要引用它,然后再次使用插值:
$dir: translateY;
$val: 42;
$i: 3;
.test {
// either of these will work
transform: #{'#{$dir}(#{$val * $i})'} scale(1);
transform: #{$dir}#{'(#{$val * $i})'} scale(1);
}