I have a website whose layout is shown in the diagram. The body consists of a main container , which consists of a header , parent div and footer . parent div also contains several child div , as shown.

The task, which is the height of all child div , is finite. But the parent div contains nothing but child divs. All child divs are visible, but the height of the parent div is zero. I also do not fix the height of the parent div by setting some given value, as this may cause an error if the number of children increases in the future.
The problem due to the zero size of the parent div is that my footer goes up and collides with the contents of the parent div. This can be resolved by providing a suitable margin, but this is not the solution I'm looking for.
Can someone suggest me a way for the height of the parent div to automatically change depending on the height of the child divs.
Please comment if I'm unclear, asking my doubts!
css css3 height parent-child
Prashant Singh Sep 22 '12 at 3:29 2012-09-22 03:29
source share