Home > DeveloperSection > Forums > Div collapse after float css
Ankit Singh

Total Post:341

Points:2389
Posted on    December-28-2012 7:49 AM

 CSS-CSS3 CSS-CSS3 
Ratings:


 1 Reply(s)
 1541  View(s)
Rate this:
Hi every one

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.

This is my code

HTML Code

<div id="nav">

        <ul id="ullistNavi">

            <li><a href="#">Home</a></li>

            <li><a href="#">About Us</a></li>

            <li><a href="#">Contact Us></a></li>

            <li><a href="#">Download</a></li>

            <li><a href="#">Service</a></li>

        </ul>

    </div>

CSS

 

<style type="text/css">

        #nav #ulListNavi a

        {

            float: left;

        }

</style>

Thanks in advance


AVADHESH PATEL

Total Post:604

Points:4228
Posted on    December-28-2012 9:28 AM

Hi Ankit Singh

you can try this

Add any overflow value other than visible to your container:

div#nav { overflow:auto; }
Then add width to restore the width

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

Don't want to miss updates? Please click the below button!

Follow MindStick