I want to animate a <div>
from 200px
to auto
height. I can’t seem to make it work though. Does anyone know how?
Here’s the code:
$("div:first").click(function(){
$("#first").animate({
height: "auto"
}, 1000 );
});
I want to animate a <div>
from 200px
to auto
height. I can’t seem to make it work though. Does anyone know how?
Here’s the code:
$("div:first").click(function(){
$("#first").animate({
height: "auto"
}, 1000 );
});
you can store it in a data attribute.
Toggle slide (Box9's answer expanded)
You can make Liquinaut's answer responsive to window size changes by adding a callback that sets the height back to auto.
this is working and it is simplier then solutions before:
CSS:
JS:
Note: This solution requires jQuery UI
you can always do this:
here is a fiddle: http://jsfiddle.net/Zuriel/faE9w/2/
Here's one that works with BORDER-BOX ...
Hi guys. Here is a jQuery plugin I wrote to do the same, but also account for the height differences that will occur when you have
box-sizing
set toborder-box
.I also included a "yShrinkOut" plugin that hides the element by shrinking it along the y-axis.
Any of the parameters I used can be omitted or set to null in order to accept default values. The parameters I used: