Q.如何给一张图片img加遮罩层?
A1.在<img>下加一个表示遮罩层的空标签
html代码:
12 3 4
css代码:
1 .container { 2 position:relative; 3 } 4 .mask { 5 background;url('mask.png') no-repeat; 6 opacity: 0.6; 7 position:absolute; 8 top:0; 9 left:0;10 }
A2.给container设置背景
css代码:
1 .container {2 background:url('mask.png') no-repeat;3 }4 img {5 opacity:0.4;6 }
background;url('mask.png') no-repeat;