Computer >> 컴퓨터 >  >> 프로그램 작성 >> 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: backwards;
         }
         @keyframes myanim {
            from {left: 0px; background-color: green;}
            to {left: 200px; background-color: blue;}
         }
      </style>
   </head>
   <body>
      <div></div>
   </body>
</html>