如何在sass / scss中转义字符串css? [英] How can I escape string css in sass/scss?
本文介绍了如何在sass / scss中转义字符串css?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含css值的字符串,我想使用它,但是使用gruntjs返回一个错误
I have a string that contain a css value and I want to use it but with gruntjs return me an error
Syntax error: Invalid CSS after " @media ": expected media query (e.g. print, screen, print and screen), was "$from-smartphon..."
这是我的var
$from-smartphone-portrait: "only screen and (min-width: 1px)";
这就是我所说的:
@media $from-smartphone-portrait {
// Smartphone portrait
body {
font-size: 12px;
line-height: 14px;
}
}
/ p>
in LESS I can escape it in this mode:
@from-smartphone-portrait: ~"only screen and (min-width: 1px)";
如何在SASS / SCSS中做同样的事?
How can I make the same thing in SASS/SCSS?
感谢
推荐答案
您可以使用 unquote
function:
You can make use of the unquote
function:
$from-smartphone-portrait: unquote("only screen and (min-width: 1px)");
要将该变量用于媒体查询定义:
To use the variable for the media query definition:
@media #{$from-smartphone-portrait} {
这篇关于如何在sass / scss中转义字符串css?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文