在CSS中,图层层遮罩是一种非常常见的技术,可以通过使用多个图层来实现这种效果。在此我们将介绍如何用CSS实现图层层遮罩。首先,我们需要创建一个具有多个层的HTML元素。每一层都需要设置其相应的CSS
<div class="layer1"></div><br>
<div class="layer2"></div><br>
<div class="layer3"></div><br>
.layer1 {<br>
position: absolute;<br>
top: 0;<br>
left: 0;<br>
width: 100%;<br>
height: 100%;<br>
background-color: red;<br>
z-index: 1;<br>
}<br>
.layer2 {<br>
position: absolute;<br>
top: 20px;<br>
left: 20px;<br>
width: 100%;<br>
height: 100%;<br>
background-color: green;<br>
z-index: 2;<br>
}<br>
.layer3 {<br>
position: absolute;<br>
top: 40px;<br>
left: 40px;<br>
width: 100%;<br>
height: 100%;<br>
background-color: blue;<br>
z-index: 3;<br>
}<br>
.layer1 {<br>
position: absolute;<br>
top: 0;<br>
left: 0;<br>
width: 100%;<br>
height: 100%;<br>
background-color: red;<br>
z-index: 1;<br>
}<br>
.layer2 {<br>
position: absolute;<br>
top: 20px;<br>
left: 20px;<br>
width: 100%;<br>
height: 100%;<br>
background-color: green;<br>
z-index: 2;<br>
}<br>
.layer3 {<br>
position: absolute;<br>
top: 40px;<br>
left: 40px;<br>
width: 100%;<br>
height: 100%;<br>
background-color: blue;<br>
z-index: 3;<br>
opacity: 0.5;<br>
}<br>
粉丝
0
关注
0
收藏
0