-1
3列2行。所以6盒。第一排3个,第二排3个。 当我减小浏览器大小时,右侧的框下降到下一行。当我缩小浏览器尺寸时,如何保留盒子?当浏览器缩小时,如何将网格行固定到网页上?
代码:
#content {
width: 1200px;
height: 840px;
background-color: #f9fafa;
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
}
.box {
height: 355px;
width: 355px;
background-color: #ffffff;
border: 1px solid #323232;
-webkit-transition: background-color 0s ease 0s;
-moz-transition: background-color 0s ease 0s;
-ms-transition: background-color 0s ease 0s;
-o-transition: background-color 0s ease 0s;
transition: background-color 0s ease 0s;
display: block;
float: left;
position: relative;
margin-top: 20px;
margin-right: 20px;
margin-bottom: 20px;
margin-left: 20px;
display: block;
}
<div id="content">
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</div>
感谢您的回答。如果我需要盒子具有特定的宽度和高度,该怎么办?如果我将宽度和高度设置为355px,它的工作原理是否相同? – 2014-09-05 05:32:47
是的,但它会在调整大小。既然你有'空白:无环'属性,那么你将不会有任何问题的元素包装到下一行,无论宽度和/或高度 – Devin 2014-09-05 19:21:27
它不适合我。你给我的代码是正确的,但我无法让它与我的代码一起工作。 – 2014-09-05 19:58:04