比方說,我有與以下規格的容器:如何創建3個相同大小的盒子?
.container {
width: 960px;
margin: 0 auto;
height: 500px;
}
現在,在中間我想補充的3盒彼此相鄰排列,平行以下規格:
.box1 {
background-color: #000;
width: 300px;
height: 200px;
}
.box2 {
background-color: #999;
width: 300px;
height: 200px;
}
.box3 {
background-color: #333;
width: 300px;
height: 200px;
}
我試着用margin-top和margin-left在每個上面,但是這很麻煩,而且讓它們看起來與它們之間有足夠的溝槽看起來一樣麻煩。什麼是創建這個最好的方法?
廣告向每個盒子元素提供「浮動:向左」,然後使用邊距使它們間隔相等。 – 2013-04-10 00:56:37