【发布时间】:2017-10-26 09:35:49
【问题描述】:
我正在尝试创建一个从弹性框底部弹出的横幅的相当简单的效果。我通过在元素的 bottom 属性上应用过渡来实现这一点(例如,从 -50px 开始并上升到 0)。
我想要实现的是内容占据了整个空间,并且在动画期间它逐渐缩小以为横幅腾出空间(并在横幅离开时重新长出来)。
不幸的是,即使横幅“在”盒子“外面”,内容仍然会缩小,以便为横幅留出空间。我想最好的解释方法是通过演示:
$('#animate').on('click', function(e) {
$('.banner').toggleClass("show");
});
.container {
display: flex;
flex-direction: column;
flex: 1;
width: 200px;
height: 200px;
border: 2px solid;
}
.content {
height: 100%;
background: red;
}
.banner {
position: relative;
display: block;
bottom: -60px;
width: 200px;
height: 50px;
background: green;
transition: bottom 3s ease-out;
}
.banner.show {
display: block;
bottom: 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="container">
<div class="content">
content
</div>
<div>
<div class="banner">
hello
</div>
</div>
</div>
<br>
<br>
<br>
<div id="animate">animate</div>
【问题讨论】:
标签: html css flexbox css-transitions