<分区>
我想创建一个 响应式 4x4 正方形网格,在整个容器的左侧和右侧边距恰好为 20 像素。此外,这将有效地消除每行第一个方 block 上的左边距,并消除每行最后一个方 block 上的右边距,因为不需要双边距.
The green color notes the 20px margins on each side.
到目前为止,我已经创建了带有百分比的正方形网格,但问题是,因为我在每个正方形的所有边上都应用了边距,所以这种方法不能保证左右边距(在容器上)每个 20 像素。
fiddle :http://jsfiddle.net/p9qdhfub/1/
HTML
<section>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</section>
CSS
div {
background: #000;
float: left;
height: 24vw;
margin: 1%;
width: 23%;
}
问题
我如何能够创建一个 4x4 响应式正方形网格,其中容器(即 section
)始终具有 20px 的 margin-left
和 margin-right
为 20px?