Harry Joy
Harry Joy

Reputation: 59660

Parent DIV height problem

When I give float:left and float:right to inner divs. The height property of their parent div doesn't works. Why? How to solve?

jsfiddle to demonstrate the problem.

Upvotes: 2

Views: 1807

Answers (3)

Nauphal
Nauphal

Reputation: 6192

Add this line before the closing of parent div

<br style="clear:both"/>

Check this

Upvotes: 6

Nicholas Wilson
Nicholas Wilson

Reputation: 9685

Harry's right. For completeness: floating the parent also works, as does adding a cleared element (or pseudo-element) at the bottom.

Upvotes: 0

Harry Joy
Harry Joy

Reputation: 59660

Give overflow: auto; in parent div. This will handle the height difference between parent and child.

Updated jsFiddle

Upvotes: 9

Related Questions