๋ฐ์ํ
๋ก๋ฉ ์ ๋๋ฉ์ด์ ๋ง๋ค๊ธฐ
์ด๋ฒ ํฌ์คํ ์์๋ ๋ก๋ฉ ์ ๋๋ฉ์ด์ ์ ๋ง๋ค์ด๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค.
HTML ์ฝ๋
loader ํด๋์ค๊ฐ์ ๊ฐ์ง div ์์ ball ํด๋์ค๊ฐ div๋ฅผ 10๊ฐ๋ฅผ ๋ง๋ค์ด์ฃผ๋๋ก ํ๋ค.
<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 ํด๋์ค๋ฅผ ์ง๋ div์ ํํ๋ฅผ ๋ง๋ค์ด ์ค ๋ค์ nth-child๋ฅผ ์ด์ฉํ์ฌ ์ ๋๋ฉ์ด์ ๋๋ ์ด๋ฅผ ์ฃผ๊ณ ๋ง์ง๋ง์ผ๋ก ํคํ๋ ์์ ํตํด ๋ณธ๊ฒฉ์ ์ผ๋ก ์์ง์์ ์ฃผ๋๋ก ํ๋ค.
body {
background-color: #b38dff;
}
.loader {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100px;
height: 100px;
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: 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);
}
}
๊ฒฐ๊ณผ๋ฌผ
๋ก๋ฉ ํ๋ฉด ์ ๋๋ฉ์ด์ ์ด ์์ฑ๋์ต๋๋ค~!๐
๋ฐ์ํ
'CSS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[CSS] ๋ง์ฐ์ค๋ฅผ ๋ฐ๋ผ๊ฐ๋ ๋์ ํจ๊ณผ ๋ง๋ค๊ธฐ๐ (9) | 2022.09.26 |
---|---|
[CSS] ์์ง์ด๋ ์ก๋ฉด์ฒด ์ ๋๋ฉ์ด์ ๐ฒ (11) | 2022.09.22 |
[CSS] ํตํต ํ๋ ๊ธ์ ํจ๊ณผ๐ฐ (8) | 2022.09.22 |
[CSS] ๋ง์ฐ์ค ์ค๋ฒ ํจ๊ณผ(Mouse Hover Effect) (4) | 2022.09.20 |
[CSS] SCSS๋ก ์จ์ด๋ธ ์ ๋๋ฉ์ด์ ๋ง๋ค๊ธฐ๐ (8) | 2022.09.19 |
๋๊ธ