I’m adding elements into a container div whose height is ‘auto’ initially. I expect its height will be updated as the children elements appended. But, actually not. Could someone help me? I just want the container div height gets updated according to the children’s height.
I used chrome debuging tool, the height of container div is less than height of children divs. Children divs are float:left.
If you’re adding floated children to a div you need to have
overflow:auto;on the parent.You can also use another element to clear the float
clear:bothwill do this.This is because floated elements are taken out of the document flow.
Here’s an example that shows you a few techniques you can use : http://jsfiddle.net/Tn5c3/
The CSS
The JS
The HTML