rlab
rlab

Reputation: 449

How to clear only one floated object?

A question about floats and clearing. Here's the fiddle. How do I get the text to appear under the red object? If I use clear: left, the text appears under the black object because it has greater height than the red one. Is it possible to get that look I'm looking for by using only float and clear?

Upvotes: 0

Views: 1041

Answers (2)

TheTechGuy
TheTechGuy

Reputation: 17354

I think you are wrong on wrong design. This is the new jsfiddle

<div id="blue">
    <div id="black"></div>
    <div id="new">      
        <div id="red"></div>
         <h2>TEXT</h2>
    </div>
</div>

Make the new div float left

#new{width:200px;float:left}

Upvotes: 1

Nick Rolando
Nick Rolando

Reputation: 26167

You need to put red div followed by the h2 tag in a containing div that floats left (you can remove the float:left from the red div. and you can remove the clear:left from h2 :)

http://jsfiddle.net/XqLFX/

Upvotes: 1

Related Questions