使用 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.