我是Sass的新手,我很安静...我想用百分比值创建一些CSS,例如:
width : 13%;
该值是sass数字运算的结果。写这个
width : $main-width + "%"
scss代码生成以下代码:
width : "13%";
CSS,实际上是行不通的,因为它应该是:
width : 13%;
写作
width : $main-width %;
结果是
width : 13 "%"
这也导致无效的CSS规则。有没有办法使Sass打印13%的内容时没有报价?
您可以尝试#。我在混入和列表中遇到了类似的问题
问题是
它总是在这些值周围加上引号,例如“ 1rem”,“ 1.25rem”,这不是正确的CSS语法。
我将其替换为:
As you can see i use #-sign with {} and + it not necessary any more. The very interesting here is that this only appear with lists/append as you can see in my outer else. You could find it at the sass reference page Division and slash If you want to use variables along with a plain CSS /, you can use #{} to insert them. For example: p { $font-size: 12px; $line-height: 30px; font: #{$font-size}/#{$line-height}; }
Hope it helps