Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.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 为众多背景图像之一添加不透明度_Css_Background Image - Fatal编程技术网

Css 为众多背景图像之一添加不透明度

Css 为众多背景图像之一添加不透明度,css,background-image,Css,Background Image,我有这个CSS样式: .Right-Side-BG { background-repeat: no-repeat; background-attachment: fixed; background-image: url(./white.svg), linear-gradient(to bottom, #598bd7, #165594); } 我需要svg图像的不透明度为0.21,如何做到这一点?您可能需要另一种方法来解决它。可以使用以下方法使整个元素(例如,包

我有这个CSS样式:

.Right-Side-BG {
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-image: url(./white.svg), linear-gradient(to bottom, #598bd7, 
    #165594);
}

我需要svg图像的不透明度为0.21,如何做到这一点?

您可能需要另一种方法来解决它。可以使用以下方法使整个元素(例如,包含图像的div)透明:

opacity: 0.5;

如果您可以确保您的其他内容不在这个div中,而是在其他元素中,这将起作用。没有“不透明度”-仅适用于背景图像的效果。

如果您的要求是只向背景添加不透明度,而不包含元素。然后可以使用伪元素
:在
之后添加背景图像。现在,您可以为其设置
不透明度
,并且必须设置
z-index:-1
使其成为背景图像。检查下面的代码段以供参考

.myDiv{
宽度:100%;
高度:100vh;
位置:相对位置;
}
.myDiv:之后{
内容:“;
背景图像:url('https://www.bmw.com/content/dam/bmw/common/all-models/4-series/gran-coupe/2017/images-and-videos/images/BMW-4-series-gran-coupe-images-and-videos-1920x1200-10.jpg.asset.1487328157424.jpg');
背景位置:中心;
背景尺寸:封面;
位置:绝对位置;
排名:0;
左:0;
右:0;
底部:0;
不透明度:0.5;
z指数:-1;
}
.孩子{
宽度:100px;
高度:100px;
背景:红色;
}


只需简单的用户不透明度:0.2或任何你想要的透明度。我只是给图像本身增加了不透明度。