日常记录
<!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">
<link type="text/css" rel="stylesheet" href="css/style.css" />
<title>CSS3图片上移显示隐藏层</title>
</head>
<body>
<div class="He">
<div class="he_box">
<img src="images/1.png" />
<div class="hezi">隐藏层</div>
</div>
<div class="he_box">
<img src="images/2.png" />
<div class="hezi">隐藏层</div>
</div>
<div class="he_box">
<img src="images/3.png" />
<div class="hezi">隐藏层</div>
</div>
<div class="he_box">
<img src="images/4.png" />
<div class="hezi">隐藏层</div>
</div>
<div class="he_box">
<img src="images/5.png" />
<div class="hezi">隐藏层</div>
</div>
<div class="he_box">
<img src="images/6.png" />
<div class="hezi">隐藏层</div>
</div>
</div>
</body>
</html>
.He{
display: flex;
justify-content: space-between;
flex-wrap: wrap;
width: 1500px;
margin: 50px auto;
}
.he_box{
background: hotpink;
width: 400px;
height: 300px;
overflow: hidden;
margin:40px 0;
position: relative;
cursor: pointer;
}
.he_box:hover img{
top: -50px;
}
.he_box img{
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
transition: 0.5s ease;
}
.he_box:hover .hezi{
top: 200px;
}
.he_box .hezi{
position: absolute;
left: 0;
top: 300px;
width: 400px;
height: 100px;
line-height: 100px;
background: #2c3f52;
transition: 0.5s ease;
text-align: center;
color: #ffffff;
font-size: 16px;
}