Through clicking on a button, I have succeeded in executing a transition of a div (through its 'height' property) to reveal some menu options. At the end of the transition, I would like the 'height' property to be set to 'auto', so that it can accommodate any change in content inside of it.
I have tried using 'max-height' in the following code but transition does not appear to work with 'max-height'. If I use 'height' then the transition works. I have tried to use javascript to set the 'height' property to 'auto' through another trigger after the transition, and then set it to its current height(not 'auto') before executing that transition to close the DIV , through a change in class, but this fails - i am guessing because setting the element height to any value takes precedence of any subsequent change in class that tries to change the same property. No JQUERY responses please.
CSS:
.sbox{
height: 0px;
transition: height 1s ease-out;
overflow: hidden;
}
.sboxopen{
max-height: 430px;
overflow: hidden;
transition: max-height 1s ease-out;
}
JAVASCRIPT: 'onclick' event
elem.className = 'sboxopen'; // Show boax
elem.className = 'sbox'; // Hide box
HTML:
<div class="sbox">
// CONTENT IN HERE
<div>
<button id="id">Show options</button>