Animate / transition height with CSS3, but using jQuery? -
i'm trying make show/ hide menu button mobile devices using media queries.
i'm aware css3 on mobile faster, of time, on mobile compared using jquery animate because of hardware acceleration, hence want use method.
i need smooth, 0.5s css3 animation 0px whatever height container is.
what i'd - or logic i'd thought of far - when clicking ui icon, toggle height of .nav>ul 0px auto.
i've tried using transition: height , adding class required bit using jquery, cannot figure out how apply css£ transform / transition height , smoothly toggle height, , i'm stuck. don't know google (have tried, trust me!).
here's working jsfiddle: http://jsfiddle.net/3v47n/ - small grey 20x20 icon trigger.
my jquery:
$('.nav span').on('click',function(){ $('.nav ul').addclass('animateheight') });
and css:
.nav { min-height: 60px; } .nav ul { height: 0; overflow: hidden; transition: height 0.5s ease; } .nav ul.animateheight { height: auto; max-height: 9999px; }
just found solution you, maybe not best solution, workaround.
as can't transition height: auto transition max-height. need set target height value close height: auto, big bigger.
see here: http://jsfiddle.net/3v47n/5/
.nav ul { max-height: 0; overflow: hidden; transition: max-height 2s ease; } .nav ul.animateheight { max-height: 999px; }
Comments
Post a Comment