Take the 2-minute tour ×

I want to control the automatic height change of the container when I add something that changes the lenght of the content. Right now, if I apply a innerHTML change on the content, the height is changed accordingly. I want to apply a transition to that height change. How can I do that? ( I can also use jQuery )

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

Record the height before changing the content, change the content, record the height after, set the height to the former height, and animate to the latter height. When the animation has completed, set the height to be automatic again. You can do this using height and animate.

Try it on JSFiddle.

share|improve this answer
add comment
<div id="containter" style="overflow:hidden">

//add something...



and when adding append to the div inside the containter:

share|improve this answer
add comment

Your Answer


