νΈλμ§μ μ λ³΄λ€ λ λΆλλ½κ³
μ½κ² μ¬μ©ν μ μλ
μ λλ©μ΄μ μ λν΄μ μμ보μ.
CSSμ μ λλ©μ΄μ
μ λλ©μ΄μ μ μμ μ€νμΌκ³Ό λ μ€νμΌμ μ§μ νλ©΄
CSSμμ μ€κ° μ€νμΌμ μλμΌλ‘ μΆκ°ν΄
μ 체μ μΌλ‘ λΆλλ½κ² λ³νλ μ λλ©μ΄μ ν¨κ³Όλ₯Ό λ§λ€μ΄ λΈλ€λ
νΈλμ§μ
κ³Ό λΉμ·ν μ±κ²©μ κ°μ§κ³ μκΈ΄ νμ§λ§,
CSS μ λλ©μ΄μ
μ μμν΄ λλ΄λ λμ μνλ κ³³ μ΄λμλ μ€νμΌμ λ°κΎΈλ©°
μ λλ©μ΄μ μ μ μν μ μλ€λ μ°¨μ΄μ μ΄ μλ€.
μ΄λ, μ λλ©μ΄μ μ€κ°μ μ€νμΌμ΄ λ°λλ μ§μ μ
'ν€νλ μ(keyframe)μ΄λΌκ³ νλ€.
CSS μ λλ©μ΄μ μμ μ¬μ©νλ μμ±
μ λλ©μ΄μ μ μ΄μ λͺ¨λ λΈλΌμ°μ λ₯Ό κ³ λ €ν΄
-webkit-, -moz-, -o- μ λμ¬λ₯Ό λΆμ¬μ μ¬μ©νλ€.
@keyframes μμ± : μ λλ©μ΄μ μ§μ μ€μ
μ λλ©μ΄μ μ μμκ³Ό λμ λΉλ‘―ν΄ μνκ° λ°λλ λΆλΆμ΄ μμ κ²½μ°
ν΄λΉ μμ±μ μ΄μ©ν΄ λ°λλ μ§μ μ μ€μ νλ κ²μΌλ‘
λ¨Όμ μΉ λ¬Έμμμ μ¬λ¬ μ λλ©μ΄μ
μ μ μν κ²μ λλΉν΄
'μ΄λ¦'μΌλ‘ μ λλ©μ΄μ μ ꡬλ³ν΄μ€ λ€μ
μ€νμΌ μμ± κ°μ΄ λ°λλ μ§μ μ 'μ νμ'λ‘ μ λ ₯ν΄ μ£Όλ©΄ λλ€.
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@keyframes</title>
<style>
div {
width: 100px;
height: 100px;
background-color: blue;
border: 2px black solid;
-webkit-animation-name: change-bg;
-moz-animation-name: change-bg;
-o-animation-name: change-bg;
animation-name: change-bg;
-webkit-animation-duration: 3s;
-moz-animation-duration: 3s;
-o-animation-duration: 3s;
animation-duration: 3s;
}
@-webkit-keyframes change-bg {
from {
background-color: blue;
}
to {
background-color: cornflowerblue;
border-radius: 50%;
}
}
@-moz-keyframes change-bg {
from {
background-color: blue;
}
to {
background-color: cornflowerblue;
border-radius: 50%;
}
}
@-o-keyframes change-bg {
from {
background-color: blue;
}
to {
background-color: cornflowerblue;
border-radius: 50%;
}
}
@keyframes change-bg {
from { /* μ λλ©μ΄μ
μμ μμ */
background-color: blue;
}
to { /* μ λλ©μ΄μ
λ μμ */
background-color: cornflowerblue;
border-radius: 50%;
}
}
</style>
</head>
<body>
<h3>μ¬κ°νμμ μμΌλ‘ μμν λ°λλ μ λλ©μ΄μ
</h3>
<div></div>
</body>
</html>
animation-name μμ± : μ λλ©μ΄μ μ΄λ¦ μ§μ
μ λλ©μ΄μ μ μ΄λ¦μΌλ‘ ꡬλΆνκΈ° μν΄ μ¬μ©νλ μμ±μΌλ‘
λΈλΌμ°μ μ λμ¬λ₯Ό λΆμ¬ μ¬μ©νλ€.
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>animation-name</title>
<style>
div {
width: 200px;
height: 200px;
border: black 2px solid;
float: left;
margin: 35px;
}
#box1 {
background-color: greenyellow;
-webkit-animation-name: shape;
-moz-animation-name: shape;
-o-animation-name: shape;
animation-name: shape;
-webkit-animation-duration: 3s;
-moz-animation-duration: 3s;
-o-animation-duration: 3s;
animation-duration: 3s;
}
#box2 {
background-color: violet;
-webkit-animation-name: rotate;
-moz-animation-name: rotate;
-o-animation-name: rotate;
animation-name: rotate;
-webkit-animation-duration: 3s;
-moz-animation-duration: 3s;
-o-animation-duration: 3s;
animation-duration: 3s;
}
@-webkit-keyframes shape {
form {border-radius: 0%;}
to {border-radius: 50%;}
}
@-moz-keyframes shape {
form {border-radius: 0%;}
to {border-radius: 50%;}
}
@-o-keyframes shape {
form {border-radius: 0%;}
to {border-radius: 50%;}
}
@keyframes shape {
form {border-radius: 0%;}
to {border-radius: 50%;}
}
@-o-keyframes rotate {
form {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
-ms-transform: rotate(0deg);
transform: rotate(0deg);
}
to {
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
}
@-moz-keyframes rotate {
form {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
-ms-transform: rotate(0deg);
transform: rotate(0deg);
}
to {
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
}
@-webkit-keyframes rotate {
form {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
-ms-transform: rotate(0deg);
transform: rotate(0deg);
}
to {
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
}
@keyframes rotate {
form {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
-ms-transform: rotate(0deg);
transform: rotate(0deg);
}
to {
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
}
</style>
</head>
<body>
<h3>@keyframeμ μ¬μ©ν΄ μ€νν μ λλ©μ΄μ
μ§μ νκΈ°</h3>
<div id="box1"></div>
<div id="box2"></div>
</body>
</html>
animation-duration μμ± : μ λλ©μ΄μ μ€νμκ° μ€μ
μ λλ©μ΄μ μ΄ μΌλ§ λμ μ¬μν κ²μΈμ§λ₯Ό μ€μ νλ κ²μ΄λ€.
animation-direction μμ± : μ λλ©μ΄μ λ°©ν₯ μ§μ
μ λλ©μ΄μ
μ΄ λλ νμ μ€μ μ λ°κΏμ μ¬μ©νλ κ²μΌλ‘
μ λλ©μ΄μ
μ΄ ν λ² μ€νλλ©΄ μλ μμΉλ‘ λλμ κ°κ² λλλ°
μ΄λ μλλλ‘ λλμκ°κ±°λ λ°λ λ°©ν₯μΌλ‘ μ λλ©μ΄μ
μ ν λ² λ μ€νν μ μλ€.
animation-iteration-count μμ± : λ°λ³΅ νμ μ§μ
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>animation-iteration-count</title>
<style>
.box {
margin-top: 50px;
margin-left: 100px;
padding: 20px;
height: 60px;
-webkit-animation-name: move;
-moz-animation-name: move;
-o-animation-name: move;
animation-name: move;
-webkit-animation-duration: 3s;
-moz-animation-duration: 3s;
-o-animation-duration: 3s;
animation-duration: 3s;
-webkit-animation-direction: normal;
-moz-animation-direction: normal;
-o-animation-direction: normal;
animation-direction: normal;
-webkit-animation-iteration-count: infinite;
-moz-animation-iteration-count: infinite;
-o-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}
@-webkit-keyframes move {
from {
width: 200px;
background-color: wheat;
opacity: 0.5;
transform: rotate(150deg) scale(0.5);
}
to {
width: 400px;
background: #ff9400;
opacity: 1;
transform: scale(1) rotate(0deg);
}
}
@-moz-keyframes move {
from {
width: 200px;
background-color: wheat;
opacity: 0.5;
transform: rotate(150deg) scale(0.5);
}
to {
width: 400px;
background: #ff9400;
opacity: 1;
transform: scale(1) rotate(0deg);
}
}
@-o-keyframes move {
from {
width: 200px;
background-color: wheat;
opacity: 0.5;
transform: rotate(150deg) scale(0.5);
}
to {
width: 400px;
background: #ff9400;
opacity: 1;
transform: scale(1) rotate(0deg);
}
}
@keyframes move {
from {
width: 200px;
background-color: wheat;
opacity: 0.5;
transform: rotate(150deg) scale(0.5);
}
to {
width: 400px;
background: #ff9400;
opacity: 1;
transform: scale(1) rotate(0deg);
}
}
</style>
</head>
<body>
<h3>무ν λ°λ³΅νλ μ λλ©μ΄μ
λ§λ€κΈ°</h3>
<div class="box"><h3>CSS3 Animation</h3></div>
</body>
</html>
animation-timing-function μμ± : μ λλ©μ΄μ μλ 곑μ
μ λλ©μ΄μ μ μμκ³Ό μ€κ°, λμμμ
μλλ₯Ό μ νν΄ μλ 곑μ μ μ§μ νλ κ²μ΄λ€.
animation μμ± : μ λλ©μ΄μ κ΄λ ¨ μμ± νκΊΌλ²μ νκΈ°
κΈΈκ³ λ³΅μ‘ν μ λλ©μ΄μ κ΄λ ¨ μμ±λ€μ κ°λ¨ν ν μ€λ‘ νννλ μμ±μ΄λ€.
κΈ°λ³Ένμ λμ΄λ μμ± μμλ μ€μνμ§ μμ§λ§
μκ° κ°μ΄ λ κ°λΌλ©΄ 첫 λ²μ§Έ μκ°μΌλ‘ <animation-time>,
λ λ²μ§Έ μκ°μ <animation-delay> μμ±μΌλ‘ κ°μ£Όνλ€.
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>animation</title>
<style>
.box {
width: 100px;
height: 100px;
margin: 70px;
-webkit-animation: rotate 1.5s infinite, background 1.5s infinite alternate;
-moz-animation: rotate 1.5s infinite, background 1.5s infinite alternate;
-o-animation: rotate 1.5s infinite, background 1.5s infinite alternate;
animation: rotate 1.5s infinite, background 1.5s infinite alternate;
}
@-webkit-keyframes rotate {
from {
transform: perspective(120px) rotateX(0deg) rotateY(0deg);
}
50% {
transform: perspective(120px) rotateX(-180deg) rotateY(0deg);
}
to {
transform: perspective(120px) rotateX(-180deg) rotateY(-180deg);
}
}
@-moz-keyframes rotate {
from {
transform: perspective(120px) rotateX(0deg) rotateY(0deg);
}
50% {
transform: perspective(120px) rotateX(-180deg) rotateY(0deg);
}
to {
transform: perspective(120px) rotateX(-180deg) rotateY(-180deg);
}
}
@-o-keyframes rotate {
from {
transform: perspective(120px) rotateX(0deg) rotateY(0deg);
}
50% {
transform: perspective(120px) rotateX(-180deg) rotateY(0deg);
}
to {
transform: perspective(120px) rotateX(-180deg) rotateY(-180deg);
}
}
@keyframes rotate {
from {
transform: perspective(120px) rotateX(0deg) rotateY(0deg);
}
50% {
transform: perspective(120px) rotateX(-180deg) rotateY(0deg);
}
to {
transform: perspective(120px) rotateX(-180deg) rotateY(-180deg);
}
}
@-webkit-keyframes background {
from { background: red;}
50% {background: green;}
to {background: blue;}
}
@-moz-keyframes background {
from { background: red;}
50% {background: green;}
to {background: blue;}
}
@-o-keyframes background {
from { background: red;}
50% {background: green;}
to {background: blue;}
}
@keyframes background {
from { background: red;}
50% {background: green;}
to {background: blue;}
}
</style>
</head>
<body>
<h3>λ κ° μ΄μμ μ λλ©μ΄μ
λμμ μ€ννκΈ°</h3>
<div class="box"></div>
</body>
</html>
ν¨κ³Όκ° νμ°νκ² λλ¬λλ λ§νΌ
μ¬μ©νλ μ½λμ μ λμ¬μ μμ΄ λ§μμ§λ κ² κ°λ€.
κ°κΈμ animation μμ±μ μ¬μ©ν΄ νκΊΌλ²μ νκΈ°ν΄μΌ κ² λ€.
< μ°Έκ³ >
Do it! HTML5+CSS3 μΉ νμ€μ μ μ
β» ν΄λΉ κΈμ μ΅λ λͺ©μ μΌλ‘ μμ±λ κΈμ λλ€ β»
λκΈ