一旦达到 div 高度,强制 div 中的列表项浮动
我有一个高度固定的 div,位于动态无序列表内。
当前列表项溢出了 div。
需要做的是浮动列表项,以便它们不会溢出 div。
I have a div with a fixed height and inside a dynamic unordered list.
Currently the list items overflow the div.
What needs to happen is to float the list items so that they do not overflow the div.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 css3 列:
这里是 jsfiddle
HTML:
CSS:
You could use css3 columns:
here is the jsfiddle
HTML:
CSS:
您可以将
div
的overflow
属性设置为各种值。如果您只是希望截断列表,您可以考虑使用
hidden
;如果您希望用户能够看到完整列表,则可以考虑使用scroll
。示例
假设您的主要标准是列表项不溢出 div。如果您希望物品以某种方式堆叠,那么可以使用不同的方法来实现此目的。主要的一个是划分你的li并浮动这些容器。
A List Apart 上有一篇关于此的文章/articles/css3multicolumn/" rel="nofollow">多列列表。
You can set the
overflow
property of thediv
to various values.You may consider using
hidden
if you simply want the list to cut off, or perhapsscroll
if you want the user to be able to see the full list.Example
This is assuming that your main criteria is for the list items to not overflow the div. If you wish for the items to stack somehow then there are different methods available to acheive this. The main one is the divide up your li's and float those containers.
There's an article about this on A List Apart on Multi Column Lists.