![image]()
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>堆叠顺序</title>
<style>
div{
width: 200px;
height: 200px;
position: absolute;
}
.box1{
background-color: pink;
/* 取值是整数,默认值是零,取值越大则显示优先级越高 */
/* 若都没有设置则按照先后顺序来显示 */
z-index: 1;
}
.box2{
background-color: blue;
left: 100px;
top: 100px;
/* 若是设置z-index为2,则蓝色盒子会被粉色盒子压在下面 */
z-index: 2;
}
</style>
</head>
<body>
<div class="box1">box1</div>
<div class="box2">box2</div>
</body>
</html>
![image]()