sus*_*oek 3 html css animation css-animations
我正在尝试使用 CSS3 动画在我的网站上调整一些容器的大小。
这是我的容器:
.new-place-wrapper {
background: #004682;
display: inline-block;
margin-top: 70px;
animation-name: newplace;
animation-duration: 1s;
animation-fill-mode: forwards;
animation-delay: 3s;
animation-timing-function: linear;
max-height: 0px;
padding: 0px 20px;
overflow: hidden;
position: relative;
z-index: 8888;
}
@keyframes newplace {
0% {
max-height: 0px;
padding: 0px 20px;
}
100% {
max-height: 9999px;
padding: 20px 20px;
}
}Run Code Online (Sandbox Code Playgroud)
<div class="new-place-wrapper" data-equalizer>
<div class="new-place-close"><i class="fa fa-times"></i></div>
<div class="inner-place-left" data-equalizer-watch>
<span>Wir sind umgezogen!</span>
Ab sofort finden Sie uns hier:
<address>
<strong>Company</strong><br>
STREET 123<br>
CITY<br><br>
PHONE
</address>
</div>
<div class="inner-place-right" data-equalizer-watch>
<a class="button radius" href="#">VCF-Karte</a>
</div>
</div>Run Code Online (Sandbox Code Playgroud)
基本上动画效果很好,但开始时有一个奇怪的滞后。首先,容器的抖动会更高。片刻之后,动画继续非常流畅。
看这里!(等待 5 秒!)
我已经阅读了一些关于转换的内容,主要结论是,您应该避免转换宽度/高度、左/右/顶部/底部,而是使用转换属性。
这些答案可能对您有所帮助:
如何在移动设备上的 CSS 或 Javascript 中平滑地设置高度动画
降低最大高度以更好地观看动画。
.new-place-wrapper {
background: #004682;
display: inline-block;
margin-top: 70px;
animation-name: newplace;
animation-duration: 1s;
animation-fill-mode: forwards;
animation-delay: 3s;
animation-timing-function: linear;
max-height: 0px;
padding: 0 20px;
overflow: hidden;
position: relative;
z-index: 8888;
}
@keyframes newplace {
0% {
max-height: 0px;
}
100% {
max-height: 309px;
padding-top: 20px;
padding-bottom:20px;
}
}Run Code Online (Sandbox Code Playgroud)
<div class="new-place-wrapper" data-equalizer>
<div class="new-place-close"><i class="fa fa-times"></i></div>
<div class="inner-place-left" data-equalizer-watch>
<span>Wir sind umgezogen!</span>
Ab sofort finden Sie uns hier:
<address>
<strong>Company</strong><br>
STREET 123<br>
CITY<br><br>
PHONE
</address>
</div>
<div class="inner-place-right" data-equalizer-watch>
<a class="button radius" href="#">VCF-Karte</a>
</div>
</div>Run Code Online (Sandbox Code Playgroud)