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个变量?否则,您需要执行字符串插值