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>