使用 CSS 設定從慢到快再到慢動作的動畫


使用 animation-timing-function 屬性,其值為 ease,可以使用 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;}
         }
         #demo1 {animation-timing-function: ease;}
      </style>
   </head>
   <body>
      <div id = "demo1">ease effect</div>
   </body>
</html>

更新時間: 2020-06-24

1K+ 瀏覽

開始你的 職業生涯

完成課程,獲取認證

開始學習
廣告
© . All rights reserved.