我需要在 SCSS 代码中定义宽度,如下所示:
#example {
width: $currentWidth + 349 !important;
}
Where $currentWidth
由循环定义。
然而,Sass 最终总是连接两个数字而不是进行算术运算。
我也尝试过:
width: #{$currentWidth + 349}px !important;
这仍然会导致串联。
我想知道我做错了什么?我知道这是非常基础的,但我似乎也找不到关于 Sass 如何处理算术的良好信息
假设$currentWidth
是一个整数。
SASS:
$currentWidth: 30;
#example {
width: unquote( ($currentWidth + 349) + 'px ' + !important );
}
CSS 输出:
#example {
width: 379px !important;
}
您可以在这里测试:
http://sass-lang.com/try.html http://sass-lang.com/try.html
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)