目前我通過添加/洗掉一個類(playing
)來移動一個 div,它作業得很好。現在我希望這更流暢,并考慮添加一些 css 影片。問題是,我不明白如何添加影片,當我洗掉或添加此類時正在播放。這甚至可能嗎?
.description-container {
position: absolute;
margin-top: -11%;
}
.description-container.playing {
margin-top: 0%;
}
我嘗試了從上到下的過渡(將播放類添加到我的 div 的結果),但它沒有用:
.description-container.playing {
animation: top-to-bottom 1s ease-in forwards;
}
@keyframes top-to-bottom {
100% {
margin-top: 0%;
}
}
我怎樣才能做到這一點?
uj5u.com熱心網友回復:
對于影片,您可以使用 CSS 屬性transition
。
看看這里。
在您的示例中,您可以使用類似
.description-container {
position: absolute;
margin-top: -11%;
transition: margin-top 5s linear;
}
.description-container.playing {
margin-top: 0%;
}
- 這意味著過渡適用于
margin-top
更改 - 影片的持續時間為 5 秒
- 并且有
linear
速度曲線
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/506578.html
標籤:javascript css 动画 网络套件 CSS动画