我們先上程式碼
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.wrap{
width: 500px;
height: 500px;
border: 1px solid red;
}
.same{
width: 100px;
height: 100px;
}
.one{
background: green;
}
.two{
background: red;
margin: -40px 0 0 40px;
}
.three{
background: blue;
margin: -40px 0 0 80px;
}
</style>
</head>
<body>
<div class="wrap">
<div class="same one"></div>
<div class="same two"></div>
<div class="same three"></div>
</div>
</body>
</html>
複製程式碼
然後我們看一下效果

.two{
background: red;
margin: -40px 0 0 40px;
opacity: 0.5;
}
複製程式碼
然後我們看一下效果

.three{
background: blue;
margin: -40px 0 0 80px;
postion:relative;
z-index:`100;
}
複製程式碼
我們在重新看一下效果

.one{
background: green;
}
.two{
background: rgba(0, 0, 0, 0.5);
margin: -40px 0 0 40px;
}
.three{
background: blue;
margin: -40px 0 0 80px;
}
複製程式碼
然後我們看一下效果

