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

CSS μ• λ‹ˆλ©”μ΄μ…˜ λ§Œλ“€κΈ° : κ΅΄λŸ¬κ°€λŠ” λ„€λͺ¨

by μ½”νŒŒμΉ΄ 2022. 8. 29.
728x90

CSS μ• λ‹ˆλ©”μ΄μ…˜ : κ΅΄λŸ¬κ°€λŠ” 단무지

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

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


1. HTML μ†ŒμŠ€

<div class="box"></div>

λ‹¨λ¬΄μ§€μ˜ κ·Έλ¦ΌμžλŠ” κ°€μƒμš”μ†Œλ‘œ μž‘μ—…ν•΄μ€„ 것이기 λ•Œλ¬Έμ—, HTML μ†ŒμŠ€λŠ” box 클래슀λ₯Ό 가진 div λ°•μŠ€ ν•˜λ‚˜λ‘œ μΆ©λΆ„ν•©λ‹ˆλ‹€.

2. CSS μ†ŒμŠ€

body {
    height: 100vh;
    background-image: linear-gradient(to top, skyblue, pink); 
}
      
.box {
    width: 50px;
    height: 50px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
}
      
.box::before {
    content: '';
    width: 50px;
    height: 5px;
    background: #000;
    position: absolute;
    top: 58px;
    left: 0;
    border-radius: 50%;
    opacity: 0.2;
    animation: shadow 0.6s linear infinite;
}
      
@keyframes shadow {
    0% {
        transform: scale(1, 1)
    }
    50% {
        transform: scale(1.2, 1)
    }
    100% {
        transform: scale(1,1)
    }
}
      
.box::after {
    content: '';
    background: yellow;
    width: 50px;
    height: 50px;
    position: absolute;
    left: 0;
    top: 0;
    border-radius: 3px;
    animation: load 0.6s linear infinite;
}
      
@keyframes load {
    17% {
        border-bottom-right-radius: 3px;
    }
    25% {
        transform: translatey(9px) rotate(22.5deg);
    }
    50% {
        transform: translatey(18px) scale(1, 0.9) rotate(45deg);
        border-bottom-right-radius: 40px;
    }
    75% {
        transform: translatey(9px) rotate(67.5deg);
    }
    100% {
        transform: translatey(0px) rotate(90deg);
    }
}

gradient은 'κΈ°μšΈμ–΄μ§'의 μ •λ„λ‚˜, κΈ°μ˜¨μ΄λ‚˜ μ••λ ₯의 'λ³€ν™” λΉ„μœ¨'을 λœ»ν•©λ‹ˆλ‹€. 즉 cssμ—μ„œ gradientλŠ” ν•œ λ°©ν–₯μ—μ„œ λ‹€λ₯Έ λ°©ν–₯으둜 색이 점차 νλ €μ§€κ±°λ‚˜, 색이 λ³€ν™”ν•˜λŠ” 효과λ₯Ό 쀄 λ•Œ μ‚¬μš©ν•˜λŠ” μ†μ„±μž…λ‹ˆλ‹€. λ°±κ·ΈλΌμš΄λ“œμ— μ€€ linear-gradient 속성은 상단을 ν–₯ν•΄(to top), skyblueμ—μ„œ pink둜 색이 λ³€ν™”ν•œλ‹€λŠ” μ˜λ―Έμž…λ‹ˆλ‹€.

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

728x90

λŒ“κΈ€

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

CSS
κ΄‘κ³  쀀비쀑