本文介绍css如何使用opacity属性为背景图像提供透明度(代码)。 可以作为参考,需要的人请参考。 希望能帮上忙。
CSS不能直接为背景图像添加opacity属性。 可以通过以下方法避免此限制: div {
width: 200px;
高: 200 px;
显示: block;
position: relative;
}
div:after {
内容: ';
背景: URL (image.jpg;
opacity: 0.5;
top: 0;
left: 0;
bottom: 0;
right: 0;
位置: absolute;
z索引:-1;
}
相关建议: