首頁  >  文章  >  web前端  >  如何使用 CSS 設定動畫的填滿模式

如何使用 CSS 設定動畫的填滿模式

王林
王林轉載
2023-09-04 08:09:021333瀏覽

如何使用 CSS 设置动画的填充模式

要使用CSS設定動畫的填滿模式,請使用animation-fill-mode屬性。它有前進、後退、雙向等值。

您可以嘗試執行以下程式碼來設定動畫的填充模式;

範例

#線上示範

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            width: 150px;
            height: 200px;
            position: relative;
            background: red;
            animation-name: myanim;
            animation-duration: 2s;
            animation-fill-mode: forwards;
         }
         @keyframes myanim {
            from {left: 0px; background-color: green;}
            to {left: 200px; background-color: blue;}
         }
      </style>
   </head>
   <body>
      <div></div>
   </body>
</html>

以上是如何使用 CSS 設定動畫的填滿模式的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:tutorialspoint.com。如有侵權,請聯絡admin@php.cn刪除