gpt4 book ai didi

html - @keyframes 不适用于 %

转载 作者:行者123 更新时间:2023-11-28 01:40:11 25 4
gpt4 key购买 nike

.car1 仅在使用 @keyframesfromto 时移动,但在使用时不移动%。谁能解释为什么会这样?

.car1 {
animation: car1 2s 2 forwards;
position: absolute;
}

@keyframes car1 {
from {transform: translateX(550px)}
to {transform: translateX(-550px)}
}

.car2 {
position: absolute;
top: 0;
animation: car2 2s 2 forwards;
}

@keyframes car2 {
0% {top: 30px}
25% {top: 130px}
40% {top: 230px}
75% {top: 330px}
}
<div class="car1">Car1</div>
<div class="car2">Car2</div>

最佳答案

.car1 {
animation: car1 2s 2 forwards;
position: absolute;
}

@keyframes car1 {
0% {transform: translateX(550px)}
100% {transform: translateX(-550px)}
}

.car2 {
position: absolute;
top: 0;
animation: car2 2s 2 forwards;
}

@keyframes car2 {
0% {top: 30px}
25% {top: 130px}
40% {top: 230px}
75% {top: 330px}
}
<div class="car1">Car1</div>
<div class="car2">Car2</div>
嘿,只需在@keyframes car1 中将 0% 和 100% 设置为正常即可!

关于html - @keyframes 不适用于 %,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50466316/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com