任何想法为什么当我缩小网站4div总是下到下一行。演示:http://autovin.org/tp/
/* Reset All Styles */
* {padding:0px; margin:0px;font-family:Segoe UI;}
/* Background */
body {background:url(images/grids.gif) white;}
/* Wrapper */
.wrapper {width:998px;margin:0 auto;}
/* Header */
.header {padding:20px 0 20px 0;}
/* Navigation */
.nav {background:#82b2c9;color:white;}
/* Content */
.content {padding:10px 0;overflow:hidden;}
/* Box */
.box {width:240px; margin:0 10px 10px 0;border:1px solid black;float:left;}
.box:nth-child(4n){margin:0;}
/* Pagination */
.pagination {clear:both;}
/* Footer */
.footer {background:#82b2c9;color:white;}
答案 0 :(得分:1)
我只使用百分比和em单位而不是像素,因为浏览器与它们更加兼容。但在你的情况下,我并没有看到人们在那么远的地方缩小。你想快速修复,但我建议从一开始就重新思考。阅读有关盒子大小和百分比的信息。盒子大小超级棒。祝你好运!
http://jsfiddle.net/sheriffderek/xr6nC/
HTML
<ul>
<li><a href="#">Your block of text</a></li>
<li><a href="#">Your block of text</a></li>
<li><a href="#">Your block of text</a></li>
<li><a href="#">Your block of text</a></li>
<li><a href="#">Your block of text</a></li>
<!-- etc. -->
</ul>
</div>
CSS
.container {
width: 100%;
max-width: 40em; /* whatever you want */
border: 1px solid red;
overflow: hidden;
}
.container ul {
padding: 0;
margin: 0;
list-style: none;
}
.container a {
width: 22%; /* this isn't perfect - but it would be 23.5% - if you were to use box-sizing: border-box; */
/* which I highly recomend you make part of your workflow in every project */
float: left;
border: 1px solid black;
min-height: 5em;
margin-right: 2%;
margin-bottom: 2%;
}
.container li a:nth-of-type(4n+4) {
margin-right: 0;
}