Use max-height in the transformation and not height. And set a value on max-height
css code
#menu#list{max-height:0;transition: max-height 0.15s ease-out;overflow: hidden;background:#d5d5d5;}#menu:hover#list{max-height:400px;transition: max-height 0.25s ease-in;}
<div id="menu">
<a>hover me</a>
<ul id="list">
<!-- Create a bunch, or not a bunch, of li's to see the timing. -->
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
</ul>
</div>
.sidemenu li ul{max-height:0px;-webkit-transition: all .3s ease;-moz-transition: all .3s ease;-o-transition: all .3s ease;-ms-transition: all .3s ease;transition: all .3s ease;}.sidemenu li:hover ul{max-height:500px;-webkit-transition: all 1s ease;-moz-transition: all 1s ease;-o-transition: all 1s ease;-ms-transition: all 1s ease;transition: all 1s ease;}
;
Set the height to auto and transition the max-height.
max height css code
div{position: absolute;width:100%;bottom:1px;left:0px;background:#111;color:#FFF;max-height:100%;/**/height:auto;/**/-webkit-transition: all 0.2s ease-in-out;-moz-transition: all 0.2s ease-in-out;-o-transition: all 0.2s ease-in-out;-ms-transition: all 0.2s ease-in-out;transition: all 0.2s ease-in-out;}.close{max-height:0%;/**/}
;
A visual workaround to animating height using CSS3 transitions is to animate the padding instead, and to set explicitly height/max-height
max height css code
div{height:0;overflow: hidden;padding:018px;-webkit-transition: all .5s ease;-moz-transition: all .5s ease;transition: all .5s ease;}div.animated{height: auto;padding:24px18px;}
;
Simplified CSS transition height:
height and width code
.our_content{/* Initially we don't want any height, and we want the contents to be hidden */max-height:0;overflow: hidden;/* Set our transitions up. */-webkit-transition: max-height 0.8s;-moz-transition: max-height 0.8s;transition: max-height 0.8s;}.outside_box:hover.our_content{/* On hover, set the max-height to something large. In this case there's an obvious limit. */max-height:200px;}
Calculate the max height by getting the height of the inner div using JQuery
javascript
$('button').bind('click',function(e){
e.preventDefault();
w =$('#outer');if(w.hasClass('collapsed')){
w.css({"max-height":$('#inner').outerHeight()+'px'});}else{
w.css({"max-height":"0px"});}
w.toggleClass('collapsed');});
This article provides some of the basic informations on width , max height , window height , height , height auto , how to make height , how to height , css overflow , overflow hidden , min height , window height , overflow auto , max height , text overflow , height , the heights , overflow , height auto , how to make height.
Wikitechy Founder, Author, International Speaker, and Job Consultant. My role as the CEO of Wikitechy, I help businesses build their next generation digital platforms and help with their product innovation and growth strategy. I'm a frequent speaker at tech conferences and events.