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

CSS 애니메이션 : 원이 돌아가는 로딩화면

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

애니메이션 만들기

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

애니메이션 : 원이 돌아가는 로딩화면

원들이 빙글빙글 돌아가는 로딩화면입니다.

html 코드 보기

<div class="loader">
  <div class="ball"></div>
  <div class="ball"></div>
  <div class="ball"></div>
  <div class="ball"></div>
  <div class="ball"></div>
  <div class="ball"></div>
  <div class="ball"></div>
  <div class="ball"></div>
  <div class="ball"></div>
  <div class="ball"></div>
</div>

css 코드 보기

body {
  background-color: darkcyan;
}
.loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50% -50%);
  width: 100px;
  height: 100px;
  animation: spin 0.6s linear infinite reverse;
}
.ball {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50% -50%);
  height: 100%;
  animation: spin 1s infinite ease-in-out;
}
.ball::after {
  position: absolute;
  content: '';
  background-color: lightcyan;
  width: 5px;
  height: 5px;
  border-radius: 100%;
  top: 0;
}
.ball:nth-child(2){
  animation-delay: -0.1s;
}
.ball:nth-child(3){
  animation-delay: -0.2s;
}
.ball:nth-child(4){
  animation-delay: -0.3s;
}
.ball:nth-child(5){
  animation-delay: -0.4s;
}
.ball:nth-child(6){
  animation-delay: -0.5s;
}
.ball:nth-child(7){
  animation-delay: -0.6s;
}
.ball:nth-child(8){
  animation-delay: -0.7s;
}
.ball:nth-child(9){
  animation-delay: -0.8s;
}
.ball:nth-child(10){
  animation-delay: -0.9s;
}

@keyframes spin {
  0% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  100% {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

See the Pen 공이 돌아가는 로딩화면 by hjkang306 (@hjkang306) on CodePen.

728x90

댓글


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

JAVASCRIPT

자세히 보기