Dragonball Online Goku Hand
본문 바로가기
CSS

[CSS] "로딩중" 을 만들어봅시다!

by 별의 코비 2022. 9. 26.
728x90

📎codepen을 이용해서 자칫 재빠른 한국인을 화나게 할 수 있는(?) 로딩 동그라미를 만들어봅시다!


동그라미 여러개로 로딩화면을 만들어보도록 할텐데
로딩화면과 흡사하여 한숨이 푹 쉬어질 수 있으니 주의바랍니다.😤


코드 소스를 알아봅시다.💻

✔️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

ball에 애니메이션과 스타일을 입혀줍니다.
body {
    background-color: skyblue;
}
.loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 110px;
    animation: spin .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: #fff;
    width: 10px;
    height: 10px;
    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)}
}

댓글