我使用內聯塊創建圖像庫,每個圖像都有自己的div和寬度。當我調整頁面大小時,出現問題,圖像調整爲屏幕寬度,這很好,但是當我下降到大約400px(移動區域)時,圖像變得非常小。使用內嵌塊屬性調整大小的響應式圖像
無論屏幕寬度如何,我如何確保圖像保持良好的尺寸?
* {
box-sizing:border-box;
}
.container {
width:80%;
}
section.portfolio {
background:
}
section.portfolio .col {
background:;
width:23.3%;
padding:10px;
margin: 5%;
display:inline-block;
vertical-align:top;
}
section.portfolio .col img {
display:inline-block;
vertical-align:top;
}
img {
max-width:100%;
height: auto;
width: auto;
}
<section class="portfolio">
<div class="container">
<div class="col">
<img src="http://images3.nike.com/is/image/DotCom/PDP_HERO/843384_001_C_PREM/air-max-1-ultra-flyknit-shoe.jpg">
</div>
<div class="col">
<img src="http://images3.nike.com/is/image/DotCom/PDP_HERO/843384_001_C_PREM/air-max-1-ultra-flyknit-shoe.jpg">
</div>
<div class="col">
<img src="http://images3.nike.com/is/image/DotCom/PDP_HERO/843384_001_C_PREM/air-max-1-ultra-flyknit-shoe.jpg">
</div>
</div>
</section>
非常感謝!除了移動媒體查詢外,我還會根據內容添加媒體查詢。 –
歡迎好友.... – repzero