This seems like a stupid question, but I've been at it for hours, and I can't get this simple thing to work.
I have an element of height 0px
.
HTML
<div class="element"> ...content... </div>
CSS
.element {
height: 0px;
overflow: hidden;
transition: height 2s;
}
Then I've got some js that checks when a button is clicked, and adds the class 'animate' to the element.
CSS
.animate {
height: auto;
}
The problem is, there is no 2 second animation whatsoever like specified in the css.
I tested the same thing, but intead of animating to height: auto;
, i've animated it to height: 150px;
.
By doing that it works, but I need to use height auto, because the height of the content will vary.
Here is a JSFiddle I've created: https://jsfiddle.net/0ctzc4hv/1/
How would I go about animating the height of the element to auto?
Thanks in advance,
David