首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CSS/SVG动画效果-三个弹跳方-正确的时间

CSS/SVG动画效果-三个弹跳方-正确的时间
EN

Stack Overflow用户
提问于 2017-06-14 17:18:10
回答 1查看 801关注 0票数 3

我基本上是在尝试重现这些跳跃圈的时机:

https://dribbble.com/shots/2991038-Typing-Status

所有三个圆圈都以相同的速度跳跃,但第一个圆直到第三个圆圈落地时才重新开始。为了我的生命,我不能正确地延迟每一个圆圈来得到正确的时机。当第一个圆圈跳到一半的时候,我就会跳到第二个圆圈的位置,但是我不能把第一个圆跳到第三个圆圈着陆后开始的地方。或许我的宽松政策需要调整,也需要时机调整?

来源:https://jsfiddle.net/88ybodjk/

代码语言:javascript
复制
@keyframes jump {
  0% {
    transform: translateY(0px);
  }
  33% {
    transform: translateY(-12px);
  }
  100% {
    transform: translateY(0px);
  }
}

.square-1 {
  animation: jump 2s ease infinite;
}

.square-2 {
  animation: jump 2s .6s ease infinite;
}

.square-3 {
  animation: jump 2s 1.2s ease infinite;
}
代码语言:javascript
复制
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 190 50" style="padding-top: 100px;">
      <rect class="square-1" x="0" width="50" height="50" style="fill:tomato"/>
    
      <rect class="square-2" x="60" width="50" height="50" style="fill:tomato"/>
      
      <rect class="square-3" x="120" width="50" height="50" style="fill:tomato"/>
    
    </svg>

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-06-14 19:19:11

假设你同时只想要一个“空中”的圆圈。

然后,应用过渡的关键帧必须只覆盖33%。

这意味着:

代码语言:javascript
复制
@keyframes jump {
  0% {
    transform: translateY(0px);
  }
  16.5% {
    transform: translateY(-12px);
  }
  33%, 100% {
    transform: translateY(0px);
  }
}

.square-1 {
  animation: jump 2s ease infinite;
}

.square-2 {
  animation: jump 2s .6s ease infinite;
}

.square-3 {
  animation: jump 2s 1.2s ease infinite;
}
代码语言:javascript
复制
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 190 50" style="padding-top: 100px;">
      <rect class="square-1" x="0" width="50" height="50" style="fill:tomato"/>
    
      <rect class="square-2" x="60" width="50" height="50" style="fill:tomato"/>
      
      <rect class="square-3" x="120" width="50" height="50" style="fill:tomato"/>
    
    </svg>

然而,由于放松,这并没有给出正确的假象。

最好是稍微增加过渡部分的持续时间。

代码语言:javascript
复制
@keyframes jump {
  0% {
    transform: translateY(0px);
  }
  25% {
    transform: translateY(-12px);
  }
  50%, 100% {
    transform: translateY(0px);
  }
}

.square-1 {
  animation: jump 2s ease infinite;
}

.square-2 {
  animation: jump 2s .6s ease infinite;
}

.square-3 {
  animation: jump 2s 1.2s ease infinite;
}
代码语言:javascript
复制
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 190 50" style="padding-top: 100px;">
      <rect class="square-1" x="0" width="50" height="50" style="fill:tomato"/>
    
      <rect class="square-2" x="60" width="50" height="50" style="fill:tomato"/>
      
      <rect class="square-3" x="120" width="50" height="50" style="fill:tomato"/>
    
    </svg>

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44550980

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档