CSS动画速度控制

标签 css animation

Demo on CodePen

<pre>
.parent
  border: 1px solid tomato
  height: 300px
  margin: 0 auto
  margin-top: 30px
  width: 80%

.box
  width: 50px
  height: 50px
  position: absolute
  animation-name: falling
  animation-iteration-count: infinite


.box-1
  background-color: lightblue
  right: 60vw
  animation-duration: 6s
  @keyframes falling
    0%
      top: -10vh
    100%
      top: 90vh

.box-2
  background-color: lightgreen
  right: 70vw
  animation-duration: 8s
  @keyframes falling
    0%
      top: -10vh
    100%
      top: 90vh
</pre>

正如您在演示中看到的那样,立方体的动画速度越靠近底部越慢。

我想在秋天制作相同速度的动画。

谢谢。

最佳答案

默认animation-timing-function在 CSS 中是 ease - 起步加速,中途减速。你需要一个 linear定时功能,速度恒定。

将框计时功能更改为线性(pen):

.box
  width: 50px
  height: 50px
  position: absolute
  animation-name: falling
  animation-iteration-count: infinite
  animation-timing-function: linear

关于CSS动画速度控制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41087833/

相关文章:

javascript - 在 IE 中打开后 html 索引元素崩溃

javascript - 滚动到时开始动画

animation - UIView.animateWithDuration 不使用信号量执行

jquery - 如何在画廊 slider 中居中对象

html - 如何根据屏幕改变高度和宽度,(最小值)

css - 自定义字体嵌入在跨浏览器中不起作用

jquery - 如何在 Safari 中使用 jQuery 查找多个背景的背景位置/背景图像等

c# - 如何在 Windows Phone 8 中执行动画

javascript - iphone html动画?

actionscript-3 - 如何修改此缓动函数以减少反弹?