用 CSS 指定动画的速度曲线


使用 animation-timing-function 设置动画的速度曲线。你可以尝试运行以下代码来实现此目的

实例

现场演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            width: 150px;
            height: 200px;
            position: relative;
            background-color: yellow;
            animation-name: myanim;
            animation-duration: 2s;
            animation-direction: alternate-reverse;
            animation-iteration-count: 3;
         }
         @keyframes myanim {
            from {left: 100px;}
            to {left: 200px;}
         }
         #demo1 {animation-timing-function: ease;}
         #demo2 {animation-timing-function: ease-in;}
      </style>
   </head>
   <body>
      <div id = "demo1">ease effect</div>
      <div id = "demo2">ease-in effect</div>
   </body>
</html>

更新于: 2020 年 6 月 24 日

274 次浏览

开启您的 职业生涯

完成课程即可获取认证

立即开始
广告
© . All rights reserved.