CSS μ λλ©μ΄μ : λ‘λ© μ λλ©μ΄μ
μ€λμ λ‘λ© νλ©΄μ²λΌ λΉκΈλΉκΈ λμκ°λ μ λλ©μ΄μ μ λ§λ€μ΄ 보λλ‘ νκ² μ΅λλ€. μμ ν΄λ³Ό μ λλ©μ΄μ μ λ€μκ³Ό κ°μ΅λλ€.
See the Pen animation λͺλ²μ§Έμ§... by mj0614k (@mj0614k) on CodePen.
1. 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>
div μμ 10κ°μ div λ°μ€λ₯Ό λ§λ€μ΄ μ€λλ€.
2. CSS μμ€
body {
background-color: pink;
}
.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: #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)
}
}
ballμ μ λλ©μ΄μ ν¨κ³Όλ₯Ό μ£Όκ³ , κ°μμμλ λ§λ€μ΄ μ€λλ€. κ°κ°μ ballμ μμ°¨μ μΌλ‘ μ λλ©μ΄μ λλ μ΄λ₯Ό 0.1μ΄μ© λ£μ΄μ€λλ€. ballμμ λ§λ μ λλ©μ΄μ μ keyframesλ₯Ό μ μ©ν΄ μ€λλ€.
μμ HTML, CSS μμ€λ₯Ό ν©μΉλ©΄ μ λλ©μ΄μ μ΄ μμ±λ©λλ€. μμμ£ ?
'CSS' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
CSS μ λλ©μ΄μ λ§λ€κΈ° : λ§μ°μ€λ₯Ό λ°λΌκ°λ λμ (13) | 2022.09.26 |
---|---|
CSS μ λλ©μ΄μ λ§λ€κΈ° : 3D λ°μ€ μ λλ©μ΄μ (9) | 2022.09.22 |
CSS μ λλ©μ΄μ λ§λ€κΈ° : ν΅ν΅ νλ κΈμ (1) | 2022.09.22 |
CSS μ λλ©μ΄μ λ§λ€κΈ° : μΉ΄λ λ€μ§κΈ° (9) | 2022.09.20 |
CSS μ λλ©μ΄μ λ§λ€κΈ° : μΌλ μ΄λ μ λλ©μ΄μ (8) | 2022.09.19 |
λκΈ