使用opacity属性和使用filter属性可以对html背景图片透明度进行设置。
1、使用opacity属性
<style type="text/css">
div {
width: 300px;
height: 300px;
background-image: url(img/3.jpg);
}
.box{
opacity: 0.5;
}
</style>
<body>
<div>背景图片</div>
<div class="box">背景图片</div>
</body>
2、使用filter属性
<style type="text/css">
div {
width: 300px;
height: 300px;
background-image: url(img/3.jpg);
}
.box{
filter: opacity(0.6);
}
</style>
<body>
<div>背景图片</div>
<div class="box">背景图片</div>
</body>
发表评论 取消回复