发布日期:2023-05-26 浏览次数:3

1、z-index属性值:当默认值为0时,z-index属性可以设置各元素之间的重叠关系。
2、z-index值大的层位于其值小的层之上。
div {
position: relative;
width: 100px;
height: 100px;
}
p {
position: absolute;
font-size: 20px;
width: 100px;
height: 100px;
}
.a {
background-color: pink;
z-index: 1;
}
.c {
background-color: green;
z-index: 2;
top: 20px;
left: 20px;
}
.b {
background-color: red;
z-index: 3;
top: -20px;
left: 40px;
}