使用 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 年 6 月 24 日

1 千+ 瀏覽

啟動您的 職業生涯

完成本課程以獲取認證

開始
廣告
© . All rights reserved.