解决图片大小长短不一致

CSS:

<style type=”text/css”>
.figure-list{
margin: 0;
padding: 0;
}
.figure-list:after{
content: “”;
display: block;
clear: both;
height: 0;
overflow: hidden;
visibility: hidden;
}
.figure-list li{
list-style: none;
float: left;
width: 23.5%;
margin: 0 2% 2% 0;
}
.figure-list figure{
position: relative;
width: 100%;
height: 0;
overflow: hidden;
margin: 0;
padding-bottom: 100%; /* 关键就在这里 */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.figure-list figure a{
display: block;
position: absolute;
width: 100%;
top: 0;
bottom: 0;
}
</style>

 

HTML:
<ul class=”figure-list”>
<li>
<figure style=”background-image:url(http://1.su.bdimg.com/skin/19.jpg)”>
<a href=”#”></a>
</figure>
</li>
<li>
<figure style=”background-image:url(http://5.su.bdimg.com/skin/3.jpg)”>
<a href=”#”></a>
</figure>
</li>
</ul>

You may also like...

发表评论