div在浮动css后折叠 [英] Div collapse after float css

查看:133
本文介绍了div在浮动css后折叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为NAV的div,在NAV的里面,我有一个UL 5 Ii,我漂浮在左边,li的,但是当我这样做NAV崩溃。我知道这是因为我在NAV周围设置了一个边框,看看它是否崩溃。这是示例。

I have a div called NAV and inside of NAV I have an UL with 5 li which I float to the left, the li's that is but when I do that the NAV collapses. I know this because I put a border around NAV to see if it collapses and it does. Here is the example.

您可以在第一个图像中看到,NAV div中的链接将左移,
黑色边框ontop是实际的div,称为NAV。

as you can see in the first image, the links in the NAV div are floated left and that black border ontop is the actual div called NAV.

在此图片中,您可以看到它如何具有顶部和底部边框,并且不会折叠。

in this image you can see how it has top and bottom border and it not collapsed.

这里是一些html和css

here is some of the html and css I used.

#nav #ulListNavi  a  {
    float: left;
}


推荐答案

添加任何溢出 以外的值

Add any overflow value other than visible to your container:

div#nav { overflow:auto; }

然后添加 width

div#nav { width: 100%; overflow:auto; }

这篇关于div在浮动css后折叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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