Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 如何在SASS变量中传递逗号?_Css_Sass - Fatal编程技术网

Css 如何在SASS变量中传递逗号?

Css 如何在SASS变量中传递逗号?,css,sass,Css,Sass,我有一个SASS变量,$active color:#a16117 现在我想在一个RGBA值中使用它,所以我创建了该变量的RGB值,就像这样,$activecolor RGB:161,97,23,我试着这样使用它, border:2px实心rgba($active color rgb 0.8)但SASS会引发此错误 error 2-basics/buttons.sass (Line 10: wrong number of arguments (1 for 4) for `rgba') 我相信它在

我有一个
SASS
变量,
$active color:#a16117

现在我想在一个
RGBA
值中使用它,所以我创建了该变量的
RGB
值,就像这样,
$activecolor RGB:161,97,23,
我试着这样使用它,
border:2px实心rgba($active color rgb 0.8)
SASS
会引发此错误

error 2-basics/buttons.sass (Line 10: wrong number of arguments (1 for 4) for `rgba')
我相信它在逗号上失败了。有没有办法解决这个问题?

试试这个:

// Declare the color as RGB; SASS will treat this as hex
$red: rgb(255,0,0);
// Declare an alpha
$alpha: .5;
// Declare another color variable as a color with an alpha
$redAlpha: rgba($red, $alpha);

使用SASS,您可以使用十六进制表示颜色,无需转换为RGB

$active-color: #a16117;
border: 2px solid rgba($active-color, .8);
如果您确实想转换为RGB,那么只需执行以下操作:

$active-color-rgb: rgb(161,97,23);
border: 2px solid rgba($active-color-rgb, .8);

JSFIDLE示例:

您可以查看有关SASS文档的更多详细信息:

为什么不为R、G和B使用3个变量?否则,您需要执行字符串插值