2017-01-17 7 views
2

У меня есть div, agent-list, который имеет классы open и closed, установленные на нем через Javascript. В 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 отлично, а React код создавал другой DIV для .open и .close. Когда я исправил это, чтобы использовать тот же 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>