Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Floating div doesn't push other div to it's right

i'm no expert when it comes to css but i'm trying to get a floating div to work. I have two div's, the top one floats left and the other div should wrap right. It seems to sort of do this. The problem is that even though it looks right, it's not actually pushing the box to the right of it. I have a jsfiddle and you'll see what i mean. i set a red border on the div called content. You'll see the content looks about right, but the dotted red line under the h1 start from the begining of the floated object instead of under the H1 title. Please help me understand. here's the jsfiddle: http://jsfiddle.net/wCnY3/

<div id="subNav">box</div><div id="content">WELCOME</div>
like image 279
Damien Avatar asked Feb 17 '23 02:02

Damien


1 Answers

Target your #content element with an overflow-x:hidden property.

#content {
    overflow-x:hidden;
}

Like so: http://jsfiddle.net/wCnY3/1/

By design, the overflow:hidden has the effect of forcing your element to behave like a square/rectangle. Since you don't have a set width/height for your element, that just means its wrapping behavior is changed.

like image 83
Richard JP Le Guen Avatar answered Mar 04 '23 05:03

Richard JP Le Guen