在下面的示例中,也可用here,WebKit(Safari 5,Chrome 10.0.648.205)和Mozilla(FF 4)都将DIV div保留在浏览器窗口的可见宽度周围,而TABLE与其内容一样宽。TABLE包含DIV
我期望DIV的增长和TABLE一样宽,但由于行为在浏览器中是一致的,我怀疑这是一个功能而不是bug。
有趣的是,如果DIV设置为float:left,it does grow as wide as the table。
任何解释?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>Wide Table</title>
<style>
#container {
background-color:blue;
/* float:left;*/
}
</style>
</head>
<body>
<div id="container">
<table >
<tr id="tr">
<td>Table Cell</td><td>Table Cell</td><td>Table Cell</td><td>Table Cell</td><td>Table Cell</td><td>Table Cell</td><td>Table Cell</td><td>Table Cell</td><td>Table Cell</td><td>Table Cell</td><td>Table Cell</td><td>Table Cell</td><td>Table Cell</td><td>Table Cell</td><td>Table Cell</td><td>Table Cell</td><td>Table Cell</td><td>Table Cell</td><td>Table Cell</td><td>Table Cell</td>
</tr>
</table>
</div>
</body>
</html>
您的问题回答了我的问题!浮动“增长”是我一直在寻找的。将显示设置为内嵌块也行得通,这也是我最终解决的问题。 – Chris 2012-06-21 20:44:58