animation

김형진·2024년 8월 12일
post-thumbnail
  • 요소를 한 스타일에서 다른 스타일로 점진적 변경 가능
animation
animation-name@keyframes 애니메이션 이름 지정
animation-duration한 주기를 완료하는데 걸리는 시간
anumation-timing-function애니메이션의 속도 곡선
animation-delay애니메이션 시작 지연
animation-iteration재생 횟수
animation-direction애니메이션 앞으로, 뒤로. 번갈아가며
animation모든 애니메이션 속성을 설정하기 위한 약식 속성

animation-direction

animation-direction
normal기본값
reverse역방향
alternate반복
alternate-reverse역방향 반

실습

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      div {
        width: 100px;
        height: 100px;
        background-color: red;
        position: relative;
        animation: name 5s linear infinite alternate;
      }
      @keyframes name {
        0% {
          background-color: lightblue;
          left: 0px;
          top: 0px;
        }
        25% {
          background-color: lightcoral;
          left: 150px;
          top: 0px;
        }
        50% {
          background-color: lightcyan;
          left: 150px;
          top: 150px;
        }
        75% {
          background-color: lightgray;
          left: 0px;
          top: 150px;
        }
        100% {
          background-color: lightcoral;
          left: 0px;
          top: 0px;
        }
      }
    </style>
  </head>
  <body>
    <div></div>
  </body>
</html>

0개의 댓글