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

CSS μ• λ‹ˆλ©”μ΄μ…˜ λ§Œλ“€κΈ° : 톡톡 νŠ€λŠ” κΈ€μž

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

CSS μ• λ‹ˆλ©”μ΄μ…˜ : 톡톡 νŠ€λŠ” κΈ€μž

μ˜€λŠ˜μ€ κΈ€μžλ“€μ΄ λ”œλ ˆμ΄λ₯Ό 두고 톡톡 νŠ€λŠ” λ“―ν•œ μ• λ‹ˆλ©”μ΄μ…˜μ΄ λ‚˜νƒ€λ‚˜λ„λ‘ μž‘μ—…ν•΄ λ³΄κ² μŠ΅λ‹ˆλ‹€. μž‘μ—…ν•΄λ³Ό μ• λ‹ˆλ©”μ΄μ…˜μ€ λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€.

See the Pen Text animation02 by mj0614k (@mj0614k) on CodePen.


1. HTML μ†ŒμŠ€

<h1>
    <span>M</span>
    <span>I</span>
    <span>N</span>
    <span>J</span>
    <span>E</span>
    <span>O</span>
    <span>N</span>
    <span>G</span>
</h1>

h1 νƒœκ·Έ μ•ˆμ— μ›ν•˜λŠ” κΈ€μž 수만큼 span νƒœκ·Έλ₯Ό μž‘μ„±ν•˜κ³ , κΈ€μžλ₯Ό ν•œ μžμ”© μž…λ ₯ν•΄ μ€λ‹ˆλ‹€.

2. CSS μ†ŒμŠ€

html, body {
    width: 100%;
    height: 100%;
    background: linear-gradient(140deg, skyblue 0%, plum 100%);
    display: flex;
    justify-content: center;
    align-items: center;
}
h1 {
    height: 100px;
}
h1 span{
    font-family: 'serif';
    font-size: 80px;
    color: #fff;
    position: relative;
    top: 20px;
    display: inline-block;
    -webkit-font-smoothing: antialiased;
    text-shadow: 0 1px 0 #ccc,
                          0 2px 0 #ccc,
                          0 3px 0 #ccc,
                          0 4px 0 #ccc,
                          0 5px 0 #ccc,
                          0 6px 0 transparent,
                          0 7px 0 transparent,
                          0 8px 0 transparent,
                          0 9px 0 transparent,
                          0 10px 10px rgba(0,0,0,0.4);
    animation: bounce 0.3s ease infinite alternate;
}
h1 span:nth-child(2) {
    animation-delay: 0.1s;
}
h1 span:nth-child(3) {
    animation-delay: 0.2s;
}
h1 span:nth-child(4) {
    animation-delay: 0.3s;
}
h1 span:nth-child(5) {
    animation-delay: 0.4s;
}
h1 span:nth-child(6) {
    animation-delay: 0.5s;
}
h1 span:nth-child(7) {
    animation-delay: 0.6s;
}
h1 span:nth-child(8) {
    animation-delay: 0.7s;
}
    
@keyframes bounce {
    100% {
        top: -20px;
        text-shadow: 0 1px 0 #ccc,
                              0 2px 0 #ccc,
                              0 3px 0 #ccc,
                              0 4px 0 #ccc,
                              0 5px 0 #ccc,
                              0 6px 0 transparent,
                              0 7px 0 transparent,
                              0 8px 0 transparent,
                              0 9px 0 transparent,
                              0 50px 25px rgba(0,0,0,0.4);
    }
}

배경색은 예쁘게 κ·ΈλΌλ°μ΄μ…˜μ„ ν•΄ μ€λ‹ˆλ‹€. κΈ€μžλ“€μ΄ κ°€μš΄λ°μ— μœ„μΉ˜ν•˜λ„λ‘ μ •λ ¬ν•΄ μ£Όκ³ , 그림자λ₯Ό λ§Œλ“€μ–΄ μ€λ‹ˆλ‹€.
font-smoothing: antialiased 속성을 μ‚¬μš©ν•˜λ©΄ κΈ€μžλ₯Ό λΆ€λ“œλŸ½κ²Œ λ§Œλ“€μ–΄ μ€λ‹ˆλ‹€.
keyframesλ₯Ό μ‚¬μš©ν•˜μ—¬ μœ„μΉ˜μ™€ 그림자 μ• λ‹ˆλ©”μ΄μ…˜μ„ μž‘μ—…ν•΄ μ€λ‹ˆλ‹€.

μœ„μ˜ HTML, CSS μ†ŒμŠ€λ₯Ό ν•©μΉ˜λ©΄ μ• λ‹ˆλ©”μ΄μ…˜μ΄ μ™„μ„±λ©λ‹ˆλ‹€. 예쁘죠?

728x90

λŒ“κΈ€

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

CSS
κ΄‘κ³  쀀비쀑