【发布时间】:2012-03-12 23:43:24
【问题描述】:
这是问题的基本illustration:
<html><head><style type="text/css">
html {width: 100%; height: 100%; background: red;}
body {width: 100%; height: 100%; background: green;}
.leftbar, .rightbar {height: 100%; background: blue;}
.leftbar {float: left;}
.rightbar {float: right;}
table {width: 100px; height: 800px; background: black; color: white;
margin: 0 auto 0 auto;}
</style></head>
<body>
<ul class="leftbar"><li>one</li><li>two</li></ul>
<ul class="rightbar"><li>alpha</li><li>beta</li></ul>
<table><tbody><tr><td>blah blah</td></tr></tbody></table>
</body>
</html>
我们可以立即看到浮动的ul 元素与包含它们的body 一样高,问题是body 没有它包含的table 高。
如何使body 足够大?在此示例中,我希望 leftbar 和 rightbar 一直向下,只要滚动允许,因此您永远看不到它们下方的任何间隙。
【问题讨论】: