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;
}