【问题标题】:How would I loop this animation?我将如何循环播放此动画?
【发布时间】:2021-12-24 07:01:22
【问题描述】:
.rotatingText {
  font-family: "Georgia", serif;
  font-style: italic;
  font-size: 18px;
  text-align: center;
}

.rotatingText-adjective {
  font-family: "Open Sans", sans-serif;
  font-size: 50px;
  font-style: normal;
  font-weight: 700;
  left: 0;
  margin-bottom: 0;
  margin-top: 50px;
  opacity: 0;
  position: absolute;
  right: 0;
  text-align: center;
  text-transform: uppercase;
  top: 0;
}

.rotatingText-adjective:nth-of-type(1) {
  animation-name: rotate;
  animation-duration: 1.5s;
  animation-delay: 0.5s;
}

.rotatingText-adjective:nth-of-type(2) {
  animation-name: rotate;
  animation-duration: 1.5s;
  animation-delay: 1.75s;
}

.rotatingText-adjective:nth-of-type(3) {
  animation-name: rotate-last;
  animation-duration: 1.5s;
  animation-delay: 3s;
  animation-fill-mode: forwards;
}

@keyframes rotate {
  0% {
    opacity: 0;
    transform: translate3d(0, 50px, 0);
  }
  
  20%, 80% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
  
  100% {
    opacity: 0;
    transform: translate3d(0, -25px, 0);
  }
}

@keyframes rotate-last {
  0% {
    opacity: 0;
    transform: translate3d(0, 50px, 0);
  }
  
    50%, 100% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

这是我的代码,我需要这个动画来循环播放,但是如果我把它放在@keyframes 中,它不会做任何事情,如果我把它放在rotation-adjective:nthOftype(x) 中它只会生成文本相互重叠。有人可以帮我吗,如果可能的话,提供一个例子吗?

ps 我知道我必须使用动画迭代计数:无限;

【问题讨论】:

  • 在您的问题中添加一些html,以便更好地理解。
  • 您提供的代码不允许我们重现您的问题并为您提供帮助。

标签: html css loops web animation


【解决方案1】:

只需将其添加到您的 css 中,动画就会无限循环。

animation-iteration-count: infinite;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多