0
時考慮到這種HTML不會換inline-block的孩子:集裝箱,最大寬度調整
<section class="wrapper clearfix">
<section class="col">
<img src="http://placehold.it/200x120" alt="">
</section>
<section class="col">
<img src="http://placehold.it/200x120" alt="">
</section>
</section>
...這CSS
@media screen and (max-width: 600px) {
.col {
max-width: 150px;
}
}
.wrapper {
max-width: 500px;
margin: 0 auto;
background: grey;
font-size: 0;
}
.col {
width: 200px;
margin-right: 100px;
display: inline-block;
}
.col:last-child {
margin-right: 0px;
}
img {
max-width: 100%;
}
DEMO - http://jsfiddle.net/j77cd856/4/
當媒體時容器不會環繞其元素查詢被激活。同樣的事情發生在浮動的孩子(這是正常的,我猜?)
我設法解決這與以下clearfix,但我仍然不知道它爲什麼會發生,或者是否有更好的方法來解決它。
.clearfix {
content: "";
display: table;
clear: both;
}
DEMO - http://jsfiddle.net/j77cd856/6/
這裏有一個簡單的例子,以更好地傳達我的問題一個問題:http://i.stack.imgur.com/Wggtj .png –
你也可以嘗試使用浮點數。 – ajmajmajma