使用 CSS 設定帶有緩慢開始和結束的動畫


使用具有ease-in-out值的 animation-timing-function 屬性,以使用 CSS 設定動畫,使其以緩慢開始和結束的速度執行

示例

即時演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            width: 150px;
            height: 200px;
            position: relative;
            background-color: #808000;
            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: ease-out;}
      </style>
   </head>
   <body>
      <div id = "demo">ease-in-out effect</div>
   </body>
</html>

更新於: 2020 年 6 月 24 日

269 次瀏覽

開啟你的職業生涯職業生涯

透過完成課程獲得認證

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