Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Animation for the automatic height change when content is resized with javascript

Animation for the automatic height change when content is resized with javascript

Problem

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 )

Problem courtesy of: Octavian

Solution

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.

Solution courtesy of: icktoofay

Discussion

View additional discussion.



This post first appeared on CSS3 Recipes - The Solution To All Your Style Problems, please read the originial post: here

Share the post

Animation for the automatic height change when content is resized with javascript

×

Subscribe to Css3 Recipes - The Solution To All Your Style Problems

Get updates delivered right to your inbox!

Thank you for your subscription

×