background: $rgbaColor; 能顯示。 background: rgba($rgbaColor,.6); 就報錯為什么呢?
賦代碼:
$color: #f36; ?//是為了方便修改 color的色值,就能整個改變效果。
.body {
? ? @if red($color) > 50 {
? ? ? ? color: #fff;
? ? }
? ? @else if red($color) < 50 {
? ? ? ? color:#000;
? ? }
}
$rgbaColor: unquote('#'+red($color));
.div {
? ? color: red($color) ; ? ?
? ? color: $rgbaColor;
? ? background: $rgbaColor; ? ?
? ? background: rgba(#255,.6);?
? ? background: rgba($rgbaColor,.6);?
}
$rgbaColor 在文中已經被轉化為了 #255
? ? ? ?background: rgba(#255,.6); ?都能夠正常解析
?但 ?background: rgba($rgbaColor,.6); ?不就等價于 ?background: rgba(#255,.6); 嗎,為什么不能正常解析呢。
解釋下:我$color: #f36; 這樣子在外層定義,是為了方便修改 color的色值,就能整個改變效果。
2017-02-07
感覺應該是
$color: #f36;//這兒定義的是顏色值
$rgbaColor:red($color);//這兒定義的是字符串
2017-02-05
這個問題,很奇怪,先取得紅色值255,為什么又用255作為r:2,g:5,b:5。
$color: #f36;
$rgbaColor:red($color);//這兒是字符串,不是顏色值
@debug $rgbaColor;
.div {
? ? background: rgba(#255,0.5);?
? ? $r:0;
$g:0;
$b:0;
? ? @if $rgbaColor >=100{
@debug $rgbaColor+">=100:";//255
$r:floor($rgbaColor / 100);
$g:floor(($rgbaColor % 100) / 10);
$b:($rgbaColor % 10);
@debug "$r is " + $r + ",$g is " + $g + ",$b is " + $b;
$r:$r*16+$r;@debug $r;
$g:$g*16+$g;@debug $g;
$b:$b*16+$b;@debug $b;
? ? }
? ? //background: rgba(#255,.6);
? ? $newColor:rgb($r,$g,$b);@debug $newColor;
background: rgba($newColor,0.5);?
}
2016-12-28
$color-a3:green;
background: rgba($color-a3,.6); ?我這樣寫都是OK的啊