DIV COLLAPSE AFTER FLOAT CSS

Ankit Singh

Total Post:341

Points:2389
Posted by  Ankit Singh
 1844  View(s)
Ratings:
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
  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: Div collapse after float css

    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; }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!