我設法使用display: inline-block
來對齊這4幅圖像,但我有2個圖像,我想把它們放在其他4幅圖像下面,我嘗試了很多方法但似乎沒有任何工作。這是我的CSS和什麼樣子的圖像像現在對齊下面和相鄰的圖像
.product1 {
display: inline-block;
margin-top: 30px;
}
.product2 {
display: inline-block;
margin-top: 30px;
}
.product3 {
display: inline-block;
margin-top: 30px;
}
.product4 {
display: inline-block;
}
.product5 {
width: 230px;
}
.product6 {
width: 230px;
}
HTML代碼的圖像:
<div class="product1">
<div class="watch1">
<img src="resources/watch1.jpg" alt="watch1" height="230" width="230" />
</div>
<div class="description">
<h5>AUDEMARS PIGUET</h5>
</div>
<div class="price">
<h6>20,700</h6>
</div>
</div>
<div class="product2">
<div class="watch2">
<img src="resources/watch2.jpg" alt="watch2" height="230" width="230" />
</div>
<div class="description">
<h5>AUDEMARS PIGUET</h5>
</div>
<div class="price">
<h6>20,700</h6>
</div>
</div>
<div class="product3">
<div class="watch3">
<img src="resources/watch3.jpg" alt="watch3" height="230" width="230" />
</div>
<div class="description">
<h5>AUDEMARS PIGUET</h5>
</div>
<div class="price">
<h6>20,700</h6>
</div>
</div>
<div class="product4">
<div class="watch4">
<img src="resources/watch4.jpg" alt="watch4" height="230" width="230" />
</div>
<div class="description">
<h5>AUDEMARS PIGUET</h5>
</div>
<div class="price">
<h6>20,700</h6>
</div>
</div>
<div class="product5">
<div class="watch5">
<img src="resources/watch5.jpg" alt="watch5" height="230" width="230" />
</div>
<div class="description">
<h5>AUDEMARS PIGUET</h5>
</div>
<div class="price">
<h6>20,700</h6>
</div>
</div>
<div class="product6">
<div class="watch6">
<img src="resources/watch6.jpg" alt="watch6" height="230" width="230" />
</div>
<div class="description">
<h5>AUDEMARS PIGUET</h5>
</div>
<div class="price">
<h6>20,700</h6>
</div>
</div>
當前狀態的屏幕快照 Screen shot
我想你應該嘗試使用Flexbox的。如果您希望這種方式在舊版瀏覽器中運行,則可能需要回退,但Flexbox是您解決這些問題的方式。你可以找到如何做到你想在這裏:https://css-tricks.com/snippets/css/a-guide-to-flexbox/ – Kamelkent
歡迎來到堆棧溢出!尋求代碼幫助的問題必須包含在問題本身**中重現它所需的最短代碼**。請參閱[**如何創建最小,完整和可驗證的示例**](http://stackoverflow.com/help/mcve) –
請提供html代碼。 –