< ul>包含浮动时的高度< li> [英] <ul> height when containing floating <li>
本文介绍了< ul>包含浮动时的高度< li>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个列表:
<ul>
<li>Number 1</li>
<li>Number 2</li>
<li>Number 3</li>
...
</ul>
所有< li>
。我需要< ul>
框的高度。如果我记得正确,这是无效的:
All the <li>
are floating. I need the height of the <ul>
box. If I remember correctly this is not valid:
<ul>
<li>Number 1</li>
<li>Number 2</li>
<li>Number 3</li>
...
<hr class="clear" />
</ul>
.clear {
clear: both;
}
我该如何做?列表中的项目数可以不同,因此我不能使用固定高度。
How can I do this? The number of items in the list can be different so I can't use fixed height.
推荐答案
:
- 添加 ul $ c $>
c>。
- 使用 clearfix 。
- Add
overflow: hidden
to theul
. - Use clearfix.
这篇关于< ul>包含浮动时的高度< li>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文