CSS ์ ๋๋ฉ์ด์ : ์ผ๋ ์ด๋ ์ ๋๋ฉ์ด์
์ค๋์ CSS์ ๋ค์ํ ์์ฑ์ ์ด์ฉํ์ฌ ์ ๋๋ฉ์ด์ ์ ๋ง๋ค์ด ๋ณด๋๋ก ํ๊ฒ ์ต๋๋ค. ์ ๋๋ฉ์ด์ ์ด๋ฆ์ ๋ญ๋ผ๊ณ ํด์ผ ํ ์ง ๋ชจ๋ฅด๊ฒ ๋ค์. ์์ ํด๋ณผ ์ ๋๋ฉ์ด์ ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
1. HTML(PUG) ์์ค
div.circle-wrap
-for (var x = 1; x<=12; x++)
div.row
-for (var y = 1; y<=12; y++)
div.circle
HTML ์์ค๋ ๋ฐ๋ณต ์์ ์ ํ๊ธฐ ๋๋ฌธ์ PUG๋ฅผ ์ด์ฉํ๋ฉด ์์ํ๊ฒ ์์ ํ ์ ์์ต๋๋ค. ์ ์์ค๋ ์ด 12๊ฐ์ row ํด๋์ค๋ฅผ ๊ฐ์ง div ์์, ๊ฐ๊ฐ 12๊ฐ์ circle ํด๋์ค๋ฅผ ๊ฐ์ง div ๋ฐ์ค๋ฅผ ๋ง๋ ๊ฒ๊ณผ ๊ฐ์ต๋๋ค.
2. CSS ์์ค
body {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
background-image: linear-gradient(45deg, #00dbde 0%, #fc00ff 100%);
}
.row {
display: flex;
}
.row .circle {
width: 10px;
height: 10px;
background: #fff;
border-radius: 50%;
margin: 5px 10px;
transform-origin: top center;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% {
transform: scale(1.1) rotate(0deg);
}
50% {
transform: scale(0.2) rotate(180deg);
}
100% {
transform: scale(1.1) rotate(360deg);
}
}
.row:nth-child(1) .circle {
animation-delay: 100ms;
}
.row:nth-child(2) .circle {
animation-delay: 200ms;
}
.row:nth-child(3) .circle {
animation-delay: 300ms;
}
.row:nth-child(4) .circle {
animation-delay: 400ms;
}
.row:nth-child(5) .circle {
animation-delay: 500ms;
}
.row:nth-child(6) .circle {
animation-delay: 600ms;
}
.row:nth-child(7) .circle {
animation-delay: 700ms;
}
.row:nth-child(8) .circle {
animation-delay: 800ms;
}
.row:nth-child(9) .circle {
animation-delay: 900ms;
}
.row:nth-child(10) .circle {
animation-delay: 1000ms;
}
.row:nth-child(11) .circle {
animation-delay: 1100ms;
}
.row:nth-child(12) .circle {
animation-delay: 1200ms;
}
body์ ๊ทธ๋ผ๋ฐ์ด์ ์ผ๋ก ๋ฐฐ๊ฒฝ์์ ์ฃผ๊ณ , flex๋ก ์์ดํ ๋ค์ ๊ฐ์ด๋ฐ ์ ๋ ฌํฉ๋๋ค. ๊ฐ๊ฐ์ circle์ ๋๋น, ๋์ด๊ฐ์ ๋ถ์ฌํ๊ณ , keyframes๋ฅผ ์์ฑํด ์ค๋๋ค. ๋ง์ง๋ง์ผ๋ก, circle ์ ๋๋ฉ์ด์ ๊ฐ๊ฐ์ ์์ฐจ์ ์ผ๋ก ์ ๋๋ฉ์ด์ ๋๋ ์ด๋ฅผ ์ ์ฉํด ์ค๋๋ค.
์์ HTML, CSS ์์ค๋ฅผ ํฉ์น๋ฉด ์ ๋๋ฉ์ด์ ์ด ์์ฑ๋ฉ๋๋ค. ๊ฐ๋จํ์ฃ ?
'CSS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
CSS ์ ๋๋ฉ์ด์ ๋ง๋ค๊ธฐ : ํตํต ํ๋ ๊ธ์ (1) | 2022.09.22 |
---|---|
CSS ์ ๋๋ฉ์ด์ ๋ง๋ค๊ธฐ : ์นด๋ ๋ค์ง๊ธฐ (9) | 2022.09.20 |
CSS ์ ๋๋ฉ์ด์ ๋ง๋ค๊ธฐ : GIF ์ด๋ฏธ์ง ์ ๋๋ฉ์ด์ ๊ตฌํํ๊ธฐ (9) | 2022.09.08 |
CSS ์ ๋๋ฉ์ด์ ๋ง๋ค๊ธฐ : ์ ๋๋ฉ์ด์ ๊ธฐ์ด (3) | 2022.09.08 |
CSS ์ ๋๋ฉ์ด์ ๋ง๋ค๊ธฐ : SVG (5) | 2022.09.08 |
๋๊ธ