我想有幾個項目水平無限(一行)堆疊,而不設置其父容器的寬度。我完全知道,將容器div設置爲寬度:1000px;會讓他們堆疊,但由於各種原因,我不想使用這個解決方案。有沒有其他的選擇?防止浮動包裝沒有設置父寬度
<html>
<head>
<style type="text/css">
div {white-space:nowrap; clear:none;}
div div {width:300px; border:1px solid black; float:left; display:inline;}
</style>
</head>
<body>
<div>
<div>x</div>
<div>x</div>
<div>x</div>
<div>x</div>
<div>x</div>
<div>x</div>
</div>
</body>
</html>
你不需要'在你給實現堆疊的例子float'那些'div's。如果你真的想'浮動',那麼你可以嘗試給每個div應用'clear:left'。 – ground5hark 2010-05-19 15:36:04