哪個 CSS 屬性用於交替迴圈中執行動畫?


使用 animation-direction 屬性可以交替方向執行動畫。該屬性與 alternate animation 值一起使用以實現此目的。

示例

線上演示

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            width: 150px;
            height: 200px;
            background-color: yellow;
            animation-name: myanim;
            animation-duration: 2s;
            animation-direction: alternate;
            animation-iteration-count: 3;
         }
         @keyframes myanim {
            from {
               background-color: green;
            }
            to {
               background-color: blue;
            }
         }
      </style>
   </head>
   <body>
      <div></div>
   </body>
</html>

更新於: 2020 年 6 月 23 日

131 次瀏覽

開啟您的 職業生涯

完成課程並獲得認證

開始
廣告