gpt4 book ai didi

animation - 如何在我的动画中调用 "loop"?

转载 作者:太空宇宙 更新时间:2023-11-04 05:01:59 24 4
gpt4 key购买 nike

我有这个动画:

#button-1
{
-webkit-animation: leaf-rotation-1 1s linear 1 alternate 1.5s;
}

#button-2
{
-webkit-animation: leaf-rotation-2 1s linear 1 alternate 4s;
}

#button-3
{
-webkit-animation: leaf-rotation-3 1s linear 1 alternate 5.5s;
}

你怎么看,它们分别在 1.5、4 和 5.5 秒执行。那么,当最后一个(在 5.5)结束时,我该如何重新启动第一个?

最佳答案

我想到的解决方案将要求您编写 3 个不同的动画,它们的时间安排得当,并在循环中无休止地运行它们。

Here's a live example of the concept

所以第一个动画以 33% 结束,第二个动画从 33 开始到 66 结束,最后以 66-100 结束。这会无限运行。

CSS:

@-webkit-keyframes width-1 {
0% {
width: 100px;
}
17% {
width: 500px;
}
33% {
width: 100px;
}
}
@-webkit-keyframes width-2 {
33% {
width: 100px;
}
50% {
width: 500px;
}
66% {
width: 100px;
}
}
@-webkit-keyframes width-3 {
66% {
width: 100px;
}
83% {
width: 500px;
}
100% {
width: 100px;
}
}
div {
background: red;
width: 100px;
}

#div1 {
-webkit-animation: width-1 1s infinite linear;
}

#div2 {
-webkit-animation: width-2 1s infinite linear;
}

#div3 {
-webkit-animation: width-3 1s infinite linear;
}

HTML

<div id="div1">Div1</div>
<div id="div2">Div2</div>
<div id="div3">Div3</div>

关于animation - 如何在我的动画中调用 "loop"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11331352/

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