Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> CSS

กำหนดจำนวนครั้งที่แอนิเมชั่นควรรันด้วย CSS


ใช้ animation-iteration-count คุณสมบัติเพื่อกำหนดจำนวนครั้งที่แอนิเมชั่นควรรันด้วย CSS

ตัวอย่างต่อไปนี้กำหนดจำนวนแอนิเมชั่นเป็น 2:

ตัวอย่าง

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

   <body>
      <div> </div>
   </body>
</html>