How do I make a parent/container DIV grow as more children DIV’s are added.
<div id="container">
<div id="child" style="height:100px;">
</div>
<div id="child2" style="height:100px;">
</div>
</div>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The only reason why your parent div would not grow with its content is if it’s content is absolute positioned or is using floats, in the former case there is nothing you can do short of resizing it with javascript, in the latter you can put the following code at the end of your floating elements:
So say both the child elements in your example have a float, the code would look like this
You can use any node, as long as you use “clear: both” on it (So
<div style="clear: both"></div>would work too).