2017-01-17 9 views
2

私はdivを持っていますとclosedがJavaScriptで設定されたagent-listです。 ChromeとFirefoxでは、アニメーションが機能しません。すぐにdivのサイズが変更されます。私はこのコードが以前に動作していたことを99%確信しており、何も間違っているとは思わない。CSSの高さの遷移がアニメーション化していません

.agent-list { 
    position: absolute; 
    z-index: 20; 
    bottom: 0; 
    background-color: $lightGrey; 
    transition: all 1.15s; 
    transition-timing-function: ease-in; 
    &.closed { 
     height: 48px; 
    } 
    &.open { 
     height: 400px; 
     overflow-y: auto; 
    } 
} 
+0

私たちに 'div'要素を教えてください。 –

答えて

1

結局のところ、CSSは結構です、とリアクトコードが.open.closeに異なるのdivを作成しました。同じdivを使用してクラスを切り替えるように修正したとき、それは機能しました。

1

私が作ったフィドルでうまくいきます。あなたの問題はJSにあると思います。 鉱山は

document.getElementById("MyElement").className = "agent-list closed"; 

https://jsfiddle.net/swmfowgp/

2

あるソリューションをご確認ください。

$(function(){ 
 
    $('button').on('click', function(e){ 
 
    e.preventDefault(); 
 
    $('.agent-list').toggleClass('open'); 
 
    }); 
 
});
body{ 
 
    position: relative; 
 
    margin: 0; 
 
    padding: 0; 
 
    height: 100%; 
 
    width: 100%; 
 
} 
 
.agent-list { 
 
    position: absolute; 
 
    z-index: 20; 
 
    top: 50px; 
 
    background-color: #565656; 
 
    transition: height 0.3s ease-in-out 0s; 
 
    height: 48px; 
 
    left: 0; 
 
    overflow: hidden; 
 
    width: 100%; 
 
    color: #ffffff; 
 
} 
 
.agent-list.open { 
 
    height: 400px; 
 
    overflow-y: auto; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
 
<button type="button">Click ME</button> 
 
<div class="agent-list"> 
 
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. 
 
</div>

関連する問題