본문 바로가기
CSS/애니메이션

CSS 애니메이션 : 구르는 박스

by 코딩 척척학사 2022. 9. 2.
728x90

애니메이션 만들기

css 애니메이션을 만들어 봅니다!

애니메이션 : 구르는 박스

데굴데굴 구르는 박스 애니메이션을 만들어 봅니다.

body {
    height: 100vh;
    background-image: linear-gradient(to top, skyblue, pink);
  }
  
  .box {
    width: 50px;
    height: 50px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
  }
  .box::before {
    content: '';
    width: 50px;
    height: 5px;
    background: #000;
    position: absolute;
    top: 58px;
    left: 0;
    border-radius: 50%;
    opacity: 0.2;
    animation: shadow 0.6s linear infinite;
  }
  
  @keyframes shadow {
    0% {
      transform: scale(1, 1)
    }
    50% {
      transform: scale(1.2, 1)
    }
    100% {
      transform: scale(1, 1)
    }
  }
  .box::after {
    content: '';
    background: lightgreen;
    width: 50px;
    height: 50px;
    position: absolute;
    left: 0;
    top: 0;
    border-radius: 3px;
    animation: load 0.6s linear infinite
  }
  
  @keyframes load {
    17% {
      border-bottom-right-radius: 3px;
    }
    25% {
      transform: translatey(9px) rotate(22.5deg);
    }
    50% {
      transform: translatey(18px) scale(1, 0.9) rotate(45deg);
      border-bottom-right-radius: 40px;
    }
    75% {
      transform: translatey(9px) rotate(67.5deg);
    }
    100% {
      transform: translatey(0px) rotate(90deg);
    }
  }

See the Pen 구르는 박스 by hjkang306 (@hjkang306) on CodePen.

728x90

댓글


HTML이 적힌 썸네일 이미지
CSS가 적힌 썸네일 이미지
JAVASCRIPT가 적힌 썸네일 이미지

JAVASCRIPT

자세히 보기