CSS:强制浮动:左侧表示 div 中的元素



不确定我是否只是没有看到树的木头,但我试图迫使一堆 DIV 向左漂浮 - 在一个受约束的块内。

我的包装器是 600px x 600px,其中我有一堆 DIV(所有,也是 600x600),我使用 jQuery 滚动到每个。 问题是,它们坐在彼此下面,而不是排成一排漂浮。

从本质上讲,我想水平滚动,而不是垂直滚动。 我确定我以前已经解决了这个问题,也许我有这样的日子,但我今天无法得到它:(

任何指示赞赏。

<style>
#parent {width:600px; height:600px;}
.kids {width:600px; height:600px; float:left;}
</style>
...
<div id="parent">
    <div class="kids"> ... some content ... </div>
    <div class="kids"> ... some content ... </div>
    <div class="kids"> ... some content ... </div>
</div>
...
<nav>
   <a>{onclick srolls #parent to left:600px}</a>
</nav>

您可以尝试使用 inline-blockwhite-space: nowrap

<style>
#parent {width:600px; height:600px; white-space: nowrap; overflow: hidden;}
.kids {display: inline-block; width:600px; height:600px;}
</style>

最新更新