<div class="productcontainer">
<div class="product"><img src="products/p1.jpg" height="75" /><br />Item 1</div>
<div class="product"><img src="products/p1.jpg" height="75" /><br />Item 2</div>
<div class="product"><img src="products/p1.jpg" height="75" /><br />Item 3<br />Test</div>
<div class="product"><img src="products/p1.jpg" height="75" /><br />Item 4</div>
<div class="product"><img src="products/p1.jpg" height="75" /><br />Item 5</div>
</div>

.productcontainer { width: 320px }
.product { width: 100px; height: 100px; display: inline-block; border: solid 1px #000000 }

为什么项目3没有在顶部对齐?

最佳答案

您需要将vertical-align: top添加到.product
有关更多信息,请参见:
http://www.brunildo.org/test/inline-block.html
http://blog.mozilla.com/webdev/2009/02/20/cross-browser-inline-block/

关于html - 为什么盒子对齐不正确?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5683461/

10-12 12:24
查看更多