λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°
CSS

CSS μ• λ‹ˆλ©”μ΄μ…˜ λ§Œλ“€κΈ° : μΌλ μ΄λŠ” μ• λ‹ˆλ©”μ΄μ…˜

by μ½”νŒŒμΉ΄ 2022. 9. 19.
728x90

CSS μ• λ‹ˆλ©”μ΄μ…˜ : μΌλ μ΄λŠ” μ• λ‹ˆλ©”μ΄μ…˜

μ˜€λŠ˜μ€ CSS의 λ‹€μ–‘ν•œ 속성을 μ΄μš©ν•˜μ—¬ μ• λ‹ˆλ©”μ΄μ…˜μ„ λ§Œλ“€μ–΄ 보도둝 ν•˜κ² μŠ΅λ‹ˆλ‹€. μ• λ‹ˆλ©”μ΄μ…˜ 이름을 뭐라고 ν•΄μ•Ό 할지 λͺ¨λ₯΄κ² λ„€μš”. μž‘μ—…ν•΄λ³Ό μ• λ‹ˆλ©”μ΄μ…˜μ€ λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€.

See the Pen Untitled by mj0614k (@mj0614k) on CodePen.


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 μ†ŒμŠ€λ₯Ό ν•©μΉ˜λ©΄ μ• λ‹ˆλ©”μ΄μ…˜μ΄ μ™„μ„±λ©λ‹ˆλ‹€. κ°„λ‹¨ν•˜μ£ ?

728x90

λŒ“κΈ€

κ°μ‚¬ν•©λ‹ˆλ‹€. πŸ¦™

CSS
κ΄‘κ³  쀀비쀑