简体   繁体   English

撇号内的SCSS变量内容

[英]SCSS variable content inside apostrophes

@mixin f1($color1, $color2){
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='$color1', endColorstr='$color2',GradientType=0);
}

What i want to do is escape the apostrophe's ability of turning $color1 into a string. 我想要做的是逃避撇号将$ color1转换为字符串的能力。 startColorstr='$color1' into startColor1str='#000000'. startColorstr ='$ color1'到startColor1str ='#000000'。

@mixin f1($color1, $color2){
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=+"'"+$color1+"'"+, endColorstr=+"'"+$color2+"'"+,GradientType=0);
}

this didnt work 这没用

apparently i had to add the variable inside brackets like '{$color}' but still that wouldnt work alone. 显然我必须在括号内添加变量,如'{$ color}',但仍然不能单独工作。 i had to also add a '#' (hash) as well like '#{$color}' (even though i was passing the value of "#333" in the mixin, it still required the # 我还必须添加'#'(哈希)以及'#{$ color}'(即使我在mixin中传递了“#333”的值,它仍然需要#

So the result looks something like this: 所以结果看起来像这样:

@mixin f1($color1,$color2){
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$color1}', endColorstr='#{$color2}',GradientType=0);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM