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.
collapsed http://img401.imageshack.us/img401/8867/collapsedze4.png
no collapsed http://img71.imageshack.us/img71/879/nocollapsedkx7.png
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.
here is some of the html and css I used.
alt text http://img301.imageshack.us/img301/5514/codejc8.png
#nav #ulListNavi a {
float: left;
}
One solution is to add a "clear:both" style to an element after the last floated anchor, for instance:
This causes the containing element to clear all floating elements before closing the containing box.
Try floating the containing element to the left too.
Your problem is because you are floating the
<A>
elements, but each of them is inside an<LI>
element.LI
s display as blocks by default, so each<LI>
is forcing it's child<A>
to begin on a new line.If you float the
<LI>
s, I think you'll solve your problem.