Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/34.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:混合rgba(白色,0.5)和纯色背景色_Css_Colors_Sass_Background Color - Fatal编程技术网

Css Sass:混合rgba(白色,0.5)和纯色背景色

Css Sass:混合rgba(白色,0.5)和纯色背景色,css,colors,sass,background-color,Css,Colors,Sass,Background Color,需要计算字体的最终颜色。在PSD中,字体的不透明度为50%,颜色为#fff,背景色为#7a4eb7。相应地,Photoshop的结果应该是#c4b5dd 我想如果背景总是一样的话,就不需要透明的颜色了 可以通过Sass实现吗 找到有关此主题的文章,但无法使其正常工作: 刚刚使用文章中的第二个mixin解决了我的问题: @mixin alpha-attribute($attribute, $color, $background) { $percent: alpha($color) * 100%

需要计算字体的最终颜色。在PSD中,字体的不透明度为
50%
,颜色为
#fff
,背景色为
#7a4eb7
。相应地,Photoshop的结果应该是
#c4b5dd

我想如果背景总是一样的话,就不需要透明的颜色了

可以通过
Sass
实现吗

找到有关此主题的文章,但无法使其正常工作:

刚刚使用文章中的第二个mixin解决了我的问题:

@mixin alpha-attribute($attribute, $color, $background) {
  $percent: alpha($color) * 100%;
  $opaque: opacify($color, 1);
  $solid-color: mix($opaque, $background, $percent);
  #{$attribute}: $solid-color;
}
然后您可以按如下方式使用它:

// Mix font color rgba($white,0.5) and solid background
.text {
    @include alpha-attribute('color', rgba($white, 0.5), $studio);
}

显示您的尝试,“不起作用”并不能解释问题。好吧,我使用了文章中名为
alpha background color
的mixin,但它对我不起作用。只是尝试了另一个
alpha attribute
,做了一些小的修改,它确实起作用了!