CSSπŸ”§/css&css3 μ• λ‹ˆλ©”μ΄μ…˜

볡합 μ• λ‹ˆλ©”μ΄μ…˜ @keyframes

hyojinny 2022. 9. 26. 11:55
λ³΅ν•©μ• λ‹ˆλ©”μ΄μ…˜ : μ—¬λŸ¬λ²ˆμ— κ±Έμ³μ„œ λ™μž‘, μžλ™μ• λ‹ˆλ©”μ΄μ…˜
μ μš©λ²• @keyframes moveBox (ν•¨μˆ˜λͺ…)
μ˜ˆμ‹œ @keyframes moveBox {
  50% { transform:translateX(500px); }
}
이름지정 ν•¨μˆ˜λͺ…은 μΉ΄λ©œν‘œκΈ°λ²• = 동사+λͺ…μ‚¬λ‘œ ν‘œν˜„
moveBox (λŒ€λ¬Έμžλ₯Ό λ‘λ²ˆμ§Έ λͺ…사뢀터) (μ€‘λ³΅λΆˆκ°€)

ex. moveBox, changeColor, fadeCover, moveBox02
%  μ• λ‹ˆλ©”μ΄μ…˜μ‹œκ°„μ— λŒ€ν•œ λ°±λΆ„μœ¨, μ• λ‹ˆλ©”μ΄μ…˜μ‹œκ°„μ΄ 1초인 κ²½μš° 50%λŠ” 0.5μ΄ˆμž„
 0%, 100%λŠ” μ μ§€μ•Šμ„κ²½μš° μ΅œμ΄ˆμƒνƒœ (0%둜 μ μ„μ‹œ μ΅œμ΄ˆμœ„μΉ˜λ‘œ μ μš©λ˜λ―€λ‘œ μƒλž΅ν•œλ‹€)
μ†μ„±μ •μ˜ animation: name duration timing-function delay iteration-count direction fill-mode;
animation: ν‚€ν”„λ ˆμž„ν•¨μˆ˜λͺ… μ‹œκ°„ [ease] [1s] λ°˜λ³΅νšŸμˆ˜ μ§„ν–‰λ°©ν–₯ μ• λ‹ˆλ©”μ΄μ…˜λμ—μ„œ λ©ˆμΆœλ•Œ
ν•„μˆ˜ animation: name duration ν•„μˆ˜!
animation-delaty μ§€μ—°μ‹œκ°„ μ§€μ • (μ• λ‹ˆλ©”μ΄μ…˜ μ‹œμž‘ν›„ μ§€μ—° μ‹œκ°„ 뒀에 μ‹œμž‘)
animation-direction μ• λ‹ˆλ©”μ΄μ…˜ μ’…λ£Œ ν›„ λ‹€μ‹œ μ²˜μŒλΆ€ν„° μ‹œμž‘ν• μ§€ μ—­λ°©ν–₯일지 μ§€μ •
animation-iteration-count μ• λ‹ˆλ©”μ΄μ…˜ 반볡 횐수 μ§€μ • (infinite λ¬΄ν•œλ°˜λ³΅)
animation-fill-mode:forwerds λ§ˆμ§€λ§‰μ—μ„œ λ©ˆμΆ”κΈ° (100%μ—μ„œ λ©ˆμΆ”κ²Œ ν• λ•Œ μ‚¬μš©, μ—†μ„κ²½μš° μ²˜μŒμœ„μΉ˜λ‘œ λ˜λŒμ•„κ°)
animation-play-state μ• λ‹ˆλ©”μ΄μ…˜ λ©ˆμΆ”κ³  λ‹€μ‹œ μ‹œμž‘ν•˜κΈ° 
animation-play-state:pause μΌμ‹œμ •μ§€

 

 

 

 

μ˜ˆμ‹œ


@keyframes moveBox {
    50% {
        transform: translate(550px, 100px);
        background: red;
    }
    100% {
        transform: translate(1100px,0);
    }
}

 

 

 

ν•€λ³Όκ²Œμž„κ°™μ€ 효과 : κ±Έλ¦¬λŠ”μ‹œκ°„ μ§€μ—°μ‹œκ°„ 가속도 λ¬΄ν•œλ°˜λ³΅ 꺼꾸둜

    animation: moveBox 2s 1s linear infinite reverse;

@keyframes moveBox {
    50% {
        transform: translate(550px, 100px);
        background: red;
    }
    100% {
        transform: translate(1100px,0);
    }
}
.main_section06 .box {
    animation: moveBox 2s 1s linear infinite;
    animation-fill-mode: forwards;
    animation-play-state: running;
}
.main_section06:hover .box  {
    animation-play-state: paused;
}

 


 

 

λ°˜λ³΅ν•˜λ‹€ 마우슀 κ°€λ”°λŒ€λ©΄ λ©ˆμΆ”κΈ° 

.main_section06:hover .box  {
    animation-play-state: paused;
}

 

 

@keyframes moveBox2 {
    40%{    transform: translate(1100px,0);
    }
    50%{    transform: translate(1100px,100px);
    }
    90%{    transform: translate(0,100px);
    }
}

.main_section07 .box {
    animation: moveBox2 2s infinite;
}

 

 

 


 

*μ‹œκ³„μΆ” 효과 λ§Œλ“€κΈ°

 

 

/* μ‹œκ³„μΆ”λ§Œλ“€κΈ° */
.main_section08 {
    position: relative;
}
@keyframes rotateClock {
    50% {
        transform: rotateZ(45deg);
    }
}

/* ease-in-out 은 λ°˜λ³΅μ• λ‹ˆλ©”μ΄μ…˜μ— μ‚¬μš© */
.main_section08 .clock {
    position: absolute;
    left: 50%;
    top: 0;
    width: 50px;
    margin-left: -25px;
    border: 1px solid red;
    transform: rotateZ(-45deg);
    transform-origin: center top;
    /* transform-origin: μ’Œν‘œμΈ‘ */
    animation: rotateClock 2s infinite ease-in-out;
}

.main_section08 .clock .line {
    width: 5px;
    height: 100px;
    background: #000;
    margin: 0 auto;
}
.main_section08 .clock .circle {
    width: 50px;
    height: 50px;
    background: #000;
    border-radius: 50%;
    margin: 0 auto;
}