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

ตั้งค่าว่าแอนิเมชั่นกำลังทำงานหรือหยุดชั่วคราวโดยใช้ CSS


ใช้ animation-play-state คุณสมบัติเพื่อกำหนดว่าแอนิเมชั่นกำลังทำงานหรือหยุดชั่วคราวด้วย CSS

คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อตั้งค่าให้ภาพเคลื่อนไหวหยุดชั่วคราว:

ตัวอย่าง

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