我已經使用overflow:auto
,但我的花車總是花費盡可能多的空間作爲他們的內容。這導致列超出屏幕尺寸。
我找到了答案在這太問題: force a div to contain floated child divs
我基本上讓我的容器包含浮動元素,並防止它倒塌。 http://jsfiddle.net/zfsjb/1/
<style>
#main {
clear: both; /* Contain floating elements */
background-color: red;
}
#main:after { /* Prevents the collapsing of the containing element. */
content: ".";
clear: both; /* */
display: block;
visibility: hidden;
line-height: 0;
height: 0;
}
#primary {
float: left;
margin: 0;
width: 20%;
background-color: yellow;
}
#secondary {
float: left;
width: 80%;
background-color: blue;
}
</style>
<div id="main">
<div id="primary">Primary</div>
<div id="secondary">Secondary</div>
</div>
謝謝,但我無法設置內容的寬度。這些邊界框由預格式確定。 – allprog 2013-03-10 07:34:00