tags:

views:

50

answers:

4

I am working on a html page where I have a header div that contains two sub div's

link: http://jsbin.com/iladi4/3

I want to have a bottom-border for the header div but that border always keeps going on top. I want the border to be at the bottom.

Please see the link.

+2  A: 

Add overflow: hidden to the #header. Demo at: JS Bin.

David Thomas
great. this works. i cant accept answer yet ...have to wait 9 more minutes. but can you explain why overflow is needed?
josh
Because, once floated, the two `div`s are removed from the document's flow which causes the parent `div` (`#header`) to be empty. Using `overflow: hidden` forces the `#header` to wrap around the floated elements.
David Thomas
@Josh, did this answer your question in the end?
David Thomas
A: 

This is happening because the inner divs aren't actually in #header. By floating them you've removed them from the normal layout. Floating #header will fix that problem but may require other tweaks to get what you want.

bemace
Just had a look at the example in @vinothkumar's answer - this forces the div to appear on the left hand side. I think @David Thomas got the correct answer - I cant explain why `overflow: hidden` would cause this though.
ClarkeyBoy
A: 

Add float:left in #header See the Demo

vinothkumar
A: 

You could also add a div below the nav div with style="clear: both;" this isn't pretty, but it works if for some reason you can't use either of the other two suggestions.

Nicknameless