前端入坑纪 37
如题,简单的一个效果,这次木有JavaScript,周末吗,轻松的来一个!
OK,first things first!项目链接
HTML 结构
<div class="mWrp">
<h2>美丽的风景:</h2>
<div id="imgsWrp clear">
<a href="javascript:;">
![](http://upload-images.jianshu.io/upload_images/4732938-ee3112a66b7a2fe9.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
</a>
<a href="javascript:;">
![](http://upload-images.jianshu.io/upload_images/4732938-0faac96c4d26cdbe.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
</a>
<a href="javascript:;">
![](http://upload-images.jianshu.io/upload_images/4732938-176a37f106c33dc2.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
</a>
<a href="javascript:;">
![](http://upload-images.jianshu.io/upload_images/4732938-dd8913e5e8048411.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
</a>
</div>
</div>
CSS 结构
body {
padding: 0;
margin: 0;
background-color: #F4F4F4;
}
p {
padding: 0;
margin: 0;
}
ul,
li {
padding: 0;
margin: 0;
list-style: none;
}
a {
text-decoration: none;
color: #525252;
}
img {
vertical-align: middle;
}
.fl {
float: left;
}
.fr {
float: right;
}
.clear::after {
display: block;
content: "";
clear: both;
}
.mWrp {
width: 100%;
margin: 0 auto;
max-width: 640px;
}
#imgsWrp a {
overflow: hidden;
float: left;
width: 25%;
box-sizing: border-box;
display: block;
padding: 5px;
}
#imgsWrp img {
transition: all 600ms cubic-bezier(0.23, 1, 0.320, 1);/*动画过渡的属性设置*/
width: 100%;
}
/*鼠标滑过放大的属性,x轴和y轴变大1.2倍*/
#imgsWrp a:hover img {
transform: scale3d(1.2, 1.2, 1)
}
包裹图片的a是向左浮动的,宽度25%,然后鼠标滑过变大图片,因为a为overflow:hidden,所以a还是原大小。这样,效果就有了!