10 回答
TA贡献1803条经验 获得超3个赞
<div class="wrap"> <div class="div"> <img src=""> </div> </div> <style> .wrap{width:50px;} .div{ width:100%; height:0px; padding-bottom:100%; position:relative; } .div img{ width:100%; height:100%; position:absolute; } </style>
TA贡献1780条经验 获得超5个赞
看看这个例子
.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; }
TA贡献1824条经验 获得超5个赞
<br> .figure-list{<br> margin: 0;<br> padding: 0;<br> }<br> .figure-list:after{<br> content: "";<br> display: block;<br> clear: both;<br> height: 0;<br> overflow: hidden;<br> visibility: hidden;<br> }<br> .figure-list li{<br> list-style: none;<br> float: left;<br> width: 23.5%;<br> margin: 0 2% 2% 0;<br> }<br> .figure-list figure{<br> position: relative;<br> width: 100%;<br> height: 0;<br> overflow: hidden;<br> margin: 0;<br> padding-bottom: 100%; /* 关键就在这里 */<br> background-position: center;<br> background-repeat: no-repeat;<br> background-size: cover;<br> }<br> .figure-list figure a{<br> display: block;<br> position: absolute;<br> width: 100%;<br> top: 0;<br> bottom: 0;<br> }<br>
添加回答
举报