transform:scale()
可以实现按比例放大或者缩小功能。
transition: all 0.5s;
延时时间
<!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 media="screen">
.wrap {
width: 1200px;
margin: 0 auto;
}
@media only screen and (max-width: 1200px) {
.wrap {
width: 100%;
}
}
li {
float: left;
list-style: none;
width: 25%;
padding: 0 10px;
box-sizing: border-box;
margin-top: 30px;
}
.item {
position: relative;
border-radius: 10px;
overflow: hidden;
}
.item img {
max-width: 100%;
border-radius: 10px;
transition: all 0.5s;
transform: scale(1.1);
}
.item .mask {
width: 100%;
height: 100%;
border-radius: 10px;
position: absolute;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.5);
transition: all 0.5s;
}
.item .txt {
position: absolute;
top: 25%;
width: 100%;
height: 100%;
}
.item .txt img.icon {
display: block;
height: 40px;
text-align: center;
margin: 0 auto;
}
.item .txt p {
color: #fff;
text-align: center;
}
.item:hover img.pic {
transform: scale(1.2);
}
.item:hover .mask {
background: rgba(0, 0, 0, 0.2);
}
</style>
</head>
<body>
<div class="wrap">
<ul>
<li>
<div class="item">
<img class="pic" src="download.jpg" alt="">
<div class="mask"></div>
<div class="txt">
<img class="icon" src="download.png" alt="">
<p>金融会计</p>
</div>
</div>
</li>
<li>
<div class="item">
<img class="pic" src="download-1.jpg" alt="">
<div class="mask"></div>
<div class="txt">
<img class="icon" src="download-1.png" alt="">
<p>政府高校</p>
</div>
</div>
</li>
<li>
<div class="item">
<img class="pic" src="download-2.jpg" alt="">
<div class="mask"></div>
<div class="txt">
<img class="icon" src="download-2.png" alt="">
<p>留学语言</p>
</div>
</div>
</li>
<li>
<div class="item">
<img class="pic" src="download-3.jpg" alt="">
<div class="mask"></div>
<div class="txt">
<img class="icon" src="download-3.png" alt="">
<p>医学教育</p>
</div>
</div>
</li>
<li>
<div class="item">
<img class="pic" src="download-4.jpg" alt="">
<div class="mask"></div>
<div class="txt">
<img class="icon" src="download-4.png" alt="">
<p>k12教育</p>
</div>
</div>
</li>
<li>
<div class="item">
<img class="pic" src="download-5.jpg" alt="">
<div class="mask"></div>
<div class="txt">
<img class="icon" src="download-5.png" alt="">
<p>司法教育</p>
</div>
</div>
</li>
<li>
<div class="item">
<img class="pic" src="download-6.jpg" alt="">
<div class="mask"></div>
<div class="txt">
<img class="icon" src="download-6.png" alt="">
<p>艺术教育</p>
</div>
</div>
</li>
<li>
<div class="item">
<img class="pic" src="download-7.jpg" alt="">
<div class="mask"></div>
<div class="txt">
<img class="icon" src="download-7.png" alt="">
<p>职业教育</p>
</div>
</div>
</li>
</ul>
</div>
</body>
</html>