Computer >> 컴퓨터 >  >> 프로그램 작성 >> CSS

CSS로 처음부터 끝까지 같은 속도로 애니메이션 설정

<시간/>

animation-timing-function 속성을 선형 값과 함께 사용하여 CSS를 사용하여 처음부터 끝까지 동일한 속도로 애니메이션을 설정합니다.

예시

<!DOCTYPE html>
<html>
   <head>
      <style>
         div {
            width: 150px;
            height: 200px;
            position: relative;
            background-color: yellow;
            animation-name: myanim;
            animation-duration: 2s;
            animation-direction: alternate-reverse;
            animation-iteration-count: 3;
         }
         @keyframes myanim {
            from {left: 100px;}
            to {left: 200px;}
         }
         #demo {animation-timing-function: linear;}
      </style>
   </head>
   <body>
      <div id = "demo">linear effect</div>
   </body>
</html>