【问题标题】:How can I rotate an image for a specific time and then stopping it slowly如何将图像旋转特定时间然后慢慢停止
【发布时间】:2019-04-02 00:05:11
【问题描述】:

我想以特定速度旋转图像特定时间(例如 2 秒),然后旋转变慢直到停止。 我不是专家,我只知道如何用 css 旋转和成像,但不知道给定的速度和结尾。

【问题讨论】:

  • 在特定事件(焦点、悬停、活动...)的 css 中使用旋转、过渡缓出效果
  • 感谢您的快速回答 :) 并感谢您的建议,我会明确地做这些事情

标签: javascript css image animation rotation


【解决方案1】:

试试这个。使用关键帧是构建动画的好方法。动画将运行 2 秒。缓出属性使动画顺利结束。 forwards 属性可防止图像恢复到其原始方向。

<img src="" class="rotation-class" />

.rotation-class {
    width: 200px;
    animation: rotate-animation 2s ease-out forwards;
}
@keyframes rotate-animation {
    from {transform: rotate(0deg);}
    to {transform: rotate(90deg);}
}    

为了使动画更快缩短动画的长度。您还可以在关键帧动画中使用百分比来进一步自定义动画。

@keyframes rotate-animation {
10% {
    transform: rotate(0deg);
}

20% {
    transform: rotate(90deg);
}
100% {
    transform: rotate(90deg);
}

}

【讨论】:

  • 天哪,非常感谢。这正是我想要的!
  • 我很高兴这就是你要找的东西 :) @Djinii
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-08-26
  • 2012-11-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多