列表不包含其浮动列表项 [英] List doesn't contain its floated list items

查看:154
本文介绍了列表不包含其浮动列表项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的代码中,ul未显示。这就像李的需要被清除,但我不能这样做,因为我有其他浮动,它会混乱。为什么没有包围它的李子,有办法使它工作? (我只在Firefox中测试)

In the following code the ul is not shown. It's like the li's need to be cleared, but I can't do that because I have other floats that it would mess with. Why doesn't the ul enclose its li's and is there a way to make it work? (I've only tested it in Firefox)

<style>
   li { float: left; }
   ul { background: #F00; }
</style>

<ul>
   <li>One</li>
   <li>Two</li>
   <li>Three</li>
</ul>


推荐答案

很容易:


  • ul 规则添加 overflow:auto

  • Add overflow: auto to the ul rule.

现场演示

我不知道你的意思是但我不能这样做,其他浮动,它会乱 - 你需要显示更多的代码,并描述你想要更好一点。

I'm not sure what you mean by "but I can't do that because I have other floats that it would mess with" - you'll need to show more of your code and describe what you want a bit better.

这篇关于列表不包含其浮动列表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆