使用 CSS 设置从头到尾速度相同的动画


使用 animation-timing-function 属性,具有的 linear 值,使用 CSS 设置从头到尾速度相同的动画

示例

实时演示

<!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;}
         }
         #demo {animation-timing-function: linear;}
      </style>
   </head>
   <body>
      <div id = "demo">linear effect</div>
   </body>
</html>

更新时间: 24-Jun-2020

221 次浏览

开启您的 职业生涯

通过完成课程获得认证

开始学习
广告
© . All rights reserved.