autoに向けてのアニメーションは出来ないので、高さを事前に取得して指定するか、もし高さが固定ならCSSで処理できます。
CSS
1ul li {
2 overflow: hidden;
3 /*height: 50px;*/
4 cursor: pointer;
5 padding: 1em 0;
6}
7ul li img {/*ADD*/
8 transition: all 1s ease 0s;
9 margin-bottom: -100px;
10}
11
12ul li.active img/*ADD*/ {
13 /*height: auto;*/
14 margin-bottom: 0;
15}
16```**動くサンプル:**[https://jsfiddle.net/3kx22v27/](https://jsfiddle.net/3kx22v27/)
17
18---
19
20高さを取得する↓サンプル。
21
22```CSS
23ul li {
24 overflow: hidden;
25 height: 50px;
26 cursor: pointer;
27 margin: 1em 0;
28 position: relative;
29 transition: all 1s ease 0s;
30}
31ul li img {
32 position: absolute;
33 top:0;
34 left:0;
35}
36
37ul li.active {
38 /*height: auto;*/
39}
JavaScript
1$( function() {
2 $( 'ul li' ).each( function() {
3 var height = $( this ).find( 'img' ).height();
4 $( this ).on( 'click', function() {
5 if ( $( this ).hasClass( 'active' ) ) {
6 $( this ).stop().animate( { 'height': '50px' }, 'slow' );
7 } else {
8 $( this ).stop().animate( { 'height': height + 'px' }, 'slow' );
9 }
10 $( this ).toggleClass( 'active' );
11 } );
12 } );
13} );
14```**動くサンプル:**[https://jsfiddle.net/3kx22v27/1/](https://jsfiddle.net/3kx22v27/1/)