我有一个容器 - 想象一下它包含应用程序中的页面。我正在使用animate.css从一个页面滑动到另一个页面。页面具有不同的高度(根据其内容),因此容器必须调整大小以适应。
我无论如何都不能使高度动画化!
CodePen(和以下代码)演示了页面之间工作的滑动动画,但容器的高度只是瞬间改变。
JavaScript(这里只是举例使用jQuery,实际上我使用的是Angular):
我无论如何都不能使高度动画化!
CodePen(和以下代码)演示了页面之间工作的滑动动画,但容器的高度只是瞬间改变。
http://codepen.io/anon/pen/jqbExY
HTML:
<button id=btn>animate</button>
<main>
<section class="first">Little content</section>
<section class="second">Lots of content ........</section>
</main>
CSS:
button {
display: block;
margin: auto;
}
main {
border: 1px solid black;
width: 400px;
margin: auto;
min-height: 100px;
height: auto;
transition: height 1s linear;
}
.first {
background-color: red;
}
.second {
background-color: green;
display: none;
}
.leave {
position: absolute;
}
JavaScript(这里只是举例使用jQuery,实际上我使用的是Angular):
$('#btn').on('click', function() {
var $first = $('.first');
$first.addClass('slideOutLeft animated leave').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend',
function(e) {
$first.hide();
});
$('.second').addClass('slideInRight animated').show();
});
main
中,它依然无法工作。http://codepen.io/anon/pen/XdmJOO - gberger