
μ λλ©μ΄μ
μμ±μ μ ν ν¨κ³Ό μμ±κ³Ό ν¨κ» CSS3μμ μλ‘ μΆκ°λλλ°, μ νλ³΄λ€ λ μ ννκ³ λΆλλ½κ² μ μ΄ κ°λ₯ν©λλ€.
ν€ νλ μ μ μνκΈ°
- μ λλ©μ΄μ ν€ νλ μμ μ λλ©μ΄μ λμμ ꡬμ±νλ λ¨κ³λ€μ μ μνλ κ² μ λλ€.
- μμκ° μ΄λ€ μνμμ(
from) μ΄λ€ μνλ‘ λ³νλμ§(to)λ₯Ό μ μ ν©λλ€.
@keyframes ν€νλ μλͺ
{
from {
}
to {
}
}
@keyframes ν€νλ μλͺ
{
0% {
}
50% {
}
100% {
}
}
animation-name μμ±
- animation-name μμ±μ νΉμ μμμμ μ μ©ν ν€ νλ μλͺ μ μ§μ ν©λλ€.
animation-name: ν€νλ μλͺ
;
animation-duration μμ±
- μ λλ©μ΄μ μ§μ μκ° μ€μ
animation-duration: μ§μμκ°;
animation-delay μμ±
- μ λλ©μ΄μ μ€ν μ§μ° μκ° μ§μ
animation-delay: μ§μ°μκ°;
animation-iterator-count μμ±
- μ λλ©μ΄μ μ κΈ°λ³ΈμΌλ‘ 1ν μ€νλκ³ μ’ λ£λ©λλ€.
- μν©μ λ°λΌ μ λλ©μ΄μ μ λ°λ³΅ν΄μ 보μ¬μ€μΌ νλ κ²½μ°μ μ¬μ© ν©λλ€.
κΈ°λ³Έ νν)
animation-iteration-count: νμ;
무ν λ°λ³΅)
animation-iteration-count: infinite;
animation-play-state μμ±
- μ λλ©μ΄μ μ μ¬μ μνλ₯Ό μ§μ ν©λλ€.
paused : μ λλ©μ΄μ
μ μ€νμ μΌμ μ μ§ ν©λλ€.
running : μ λλ©μ΄μ
μ μ€νν©λλ€.
μ ν ν¨κ³Ό μμ±κ³Ό λ€λ₯΄κ² μ λλ©μ΄μ
μ μμ±κ³Ό μ€ν λμ€ μΌμ μ μ§νκ±°λ μ¬μ€ν ν μ μμ΅λλ€.
ν΄λΉ κΈ°λ₯μ μλ°μ€ν¬λ¦½νΈμ κΈ°λ₯μ΄ νμ ν©λλ€.
animation-direction μμ±
- μ λλ©μ΄μ μ μ§ν λ°©ν₯ μ§μ

animation μμ±μΌλ‘ νλ²μ μ§μ νκΈ°
- μμ±κ°μ μ λΆ λ€ μ μ νμλ μκ³ , νμν νλͺ©λ§ μ μ΄λ λ©λλ€.
μμ 1
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.container {
width: 100px;
height: 100px;
background-color: antiquewhite;
/* 무νλ°λ³΅ */
animation-iteration-count: infinite;
animation-name: bgChange;
animation-duration: 5s;
}
@keyframes bgChange {
0% {background-color: red;}
25% {background-color: orange;}
50% {background-color: yellow;}
100% {background-color: green;}
}
</style>
</head>
<body>
<div class="container"></div>
</body>
</html>

μμ 2
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
#container {
width: 500px;
/* top, bottom 20px / autoλ μ’μ° μ€κ° μ λ ¬ */
margin: 20px auto;
}
.box {
width: 100px;
height: 100px;
float: left;
margin: 50px;
}
#box1 {
background-color: #4cff00;
border: 1px solid transparent;
animation-name: shape;
animation-duration: 3s;
animation-iteration-count: 10;
}
#box2 {
background-color: #8f06b0;
border: 1px solid transparent;
animation-name: rotate;
animation-duration: 3s;
animation-iteration-count: 10;
}
@keyframes shape {
from {
border: 1px solid transparent;
}
to {
border: 1px solid #000;
border-radius: 50%;
}
}
@keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(45deg);
}
}
</style>
</head>
<body>
<div id="container">
<div class="box" id="box1"></div>
<div class="box" id="box2"></div>
</div>
</body>
</html>

μμ 3
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>μ λλ©μ΄μ
μΌμ μ μ§, μ¬μ€ν</title>
<style>
div {
width: 100px;
height: 100px;
background-color: red;
position: relative;
animation-name: move;
animation-duration: 10s;
animation-fill-mode: forwards;
animation-play-state: paused;
}
@keyframes move {
from {
left: 0;
}
to {
left: 300px;
}
}
</style>
</head>
<body>
<div>
<button id="start">μμ</button>
<button id="paused">μΌμμ μ§</button>
</div>
<script>
const box = document.querySelector("div");
document.getElementById("start").addEventListener("click", function() {
box.style.animationPlayState = "running";
})
document.getElementById("paused").addEventListener("click", function() {
box.style.animationPlayState = "paused";
})
</script>
</body>
</html>'π¨ Frontend > HTML & CSS' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
| CSS β€ μΉ ν°νΈ, μμ΄μ½ ν°νΈ μ¬μ©νκΈ° + μ€μ΅μμ (0) | 2023.03.16 |
|---|---|
| CSS β£ μ ν ν¨κ³Ό - (3) λ³ν ν¨κ³Ό(transform) (0) | 2023.03.16 |
| CSS β£ μ ν ν¨κ³Ό - (1) transition, μ€μ΅ μμ (μΌνλͺ° μν λͺ©λ‘) (2) | 2023.03.15 |
| CSS β β’ νμ μμ± - (3) μ°μ΅ λ¬Έμ (2) | 2023.03.15 |
| CSS β β’ νμ μμ± - (2) νλ©΄ λ°°μΉ (1) | 2023.03.15 |