βΆ νΈλμ§μ
νΈλμ§μ (transition)μ λ³νμ λμ΄ νλμ μ€νμΌμμ λ€λ₯Έ μ€νμΌλ‘ μμ ν λ°κΎΌλ€.
β
β
β
*νΈλμ§μ μ΄λ?
νΈλμ§μ (transition)μ΄λ μΉ μμμ λ°°κ²½ μμ΄ λ°λκ±°λ λνμ ν λλ¦¬κ° μνμΌλ‘ λ°λλ κ²μ²λΌ μ€νμΌ μμ±μ΄ λ°λλ κ²μ λ§νλ€.
μμ± |
μ€λͺ |
transition-property |
νΈλμ§μ λμμ μ€μ νλ€. |
transition-duration |
νΈλμ§μ μ§ν μκ°μ μ€μ νλ€. |
transition-timing-function |
νΈλμ§μ μλ 곑μ μ μ€μ νλ€. |
transition-delay |
νΈλμ§μ μ§μ° μκ°μ μ€μ νλ€. |
transition |
transition-propertyμ transition-duration, transition-timing-function, transition-delay μμ±μ νκΊΌλ²μ μ€μ νλ€. |
β
β
β
*transition-property μμ± - νΈλμ§μ μ μ μ©ν μμ± μ§μ νκΈ°
νΈλμ§μ μ λ§λλ 첫 λ²μ§Έ λ¨κ³λ νΈλμ§μ μ μ΄λ μμ±μ μ μ©ν κ²μΈμ§ μ ννλ κ²μ΄λ€. transition-property μμ±μΌλ‘ μ΄κ²μ κ²°μ νλ€. transition-propertyλ₯Ό μ¬μ©νμ§ μμ κ²½μ°, λͺ¨λ μμ±μ΄ νΈλμ§μ λμμ΄ λκ³ νΉμ μμ± μ΄λ¦μ μ λ ₯νλ©΄ κ·Έ μμ±μ νΈλμ§μ μ΄ μ μ©λλ€.
μμ± κ° |
μ€λͺ |
all |
all κ°μ μ¬μ©νκ±°λ transition-propertyλ₯Ό μλ΅ν κ²½μ°, μμμ λͺ¨λ μμ±μ΄ νΈλμ§μ λμμ΄ λλ€. |
none |
νΈλμ§μ λμ μ무 μμ±λ λ°λμ§ μλλ€. |
<μμ± μ΄λ¦> |
νΈλμ§μ ν¨κ³Όλ₯Ό μ μ©ν μμ± μ΄λ¦μ μ§μ νλ€. μλ₯Ό λ€μ΄ λ°°κ²½ μλ§ λ°κΏ κ²μΈμ§, width κ°μ λ°κΏ κ²μΈμ§ μνλ λμλ§ κ³¨λΌ μ§μ ν μ μλ€. μμ±μ΄ μ¬λ¬ κ°μΌ κ²½μ°, μΌν(,)λ‘ κ΅¬λΆν΄ λμ΄νλ€. |
transition-property: all; /* ν΄λΉ μμμ λͺ¨λ μμ±μ νΈλμ§μ μ μ© */ transition-property: background-color; /* ν΄λΉ μμμ λ°°κ²½ μμ νΈλμ§μ μ¬μ© */ transition-property: width, height; /* ν΄λΉ μμμ λλΉμ λμ΄μ νΈλμ§μ μ μ© */ |
β
β
*transition-duration μμ± - νΈλμ§μ μ§ν μκ° μ§μ νκΈ°
transition-propertyμμ νΈλμ§μ λμμ μ§μ νλ€λ©΄ μ§ν μκ°μ μ§μ ν΄μΌ κ·Έ μκ° λμ μμ±μ΄ μμ°μ€λ½κ² λ°λλ μ λλ©μ΄μ ν¨κ³Όλ₯Ό λ§λ€ μ μλ€. transition-duration μμ±, μ¦ νΈλμ§μ μ§ν μκ°μ΄ 0μ΄λ₯Ό κΈ°λ³ΈμΌλ‘ μ€μ λμ΄ μκΈ° λλ¬Έμ΄λ€. μ΄λ μκ° λ¨μλ μ΄(seconds) λλ λ°λ¦¬μ΄(milliseconds)μ΄λ€. νΈλμ§μ λμμ΄ λλ μμ±μ΄ μ¬λ¬ κ°λΌλ©΄ νΈλμ§μ μ§ν μκ°λ μΌν(,)λ‘ κ΅¬λΆν΄ μμλλ‘ μ¬λ¬ κ°λ₯Ό μ§μ ν μ μλ€.
β
κΈ°λ³Έν)
transition-duration: <μκ°> |
<style>
.tr1 {
width: 100px;
height: 100px;
background-color: blue;
border: 1px solid black;
-webkit-transition-property: width, height;
-moz-transition-property: width, height;
-o-transition-property: width, height;
transition-property: width, height;
-webkit-transition-duration: 2s, 1s;
-moz-transition-duration: 2s, 1s;
-o-transition-duration: 2s, 1s;
transition-duration: 2s, 1s;
}
.tr1:hover {
width:200px;
height:120px;
}
</style>
<body>
<div class="tr1"></div>
</body>
β
<style>
.tr1 {
width: 100px;
height: 100px;
background-color: red;
border: 1px solid black;
-webkit-transition-property: background-color, transform, width, height;
-moz-transition-property: background-color, transform, width, height;
-o-transition-property: background-color, transform, width, height;
transition-property: background-color, transform, width, height;
-webkit-transition-duration: 2s, 3s;
-moz-transition-duration: 2s, 3s;
-o-transition-duration: 2s, 3s;
transition-duration: 2s, 3s;
}
.tr1:hover {
width: 200px;
height: 200px;
background-color: #ff6e5f;
-webkit-transform: rotate(180deg);
-moz-transform: rotate(180deg);
-o-transform: rotate(180deg);
-ms-transform: rotate(180deg);
transform: rotate(180deg);
}
</style>
<body>
<div class="tr1"><h1>!</h1> </div>
</body>
β
β
*transition-timing-function μμ± - νΈλμ§μ μλ 곑μ μ§μ νκΈ°
transition-timing-function μμ±μ μ¬μ©νλ©΄ μμκ³Ό μ€κ°, λμμμ μλλ₯Ό μ§μ ν΄ μλ 곑μ μ λ§λ€ μ μλ€.
μλ 곑μ μ 미리 μ ν΄μ§ ν€μλλ 'λ² μ§μ 곑μ 'μ μ΄μ©ν΄ νννλ€.
β
κΈ°λ³Έν)
transition-timing-function: linear | ease | ease-in | ease-out | ease-in-out | cubic-bezier(n, n, n, n) |
μμ± κ° |
μ€λͺ |
linear |
μμλΆν° λκΉμ§ λκ°μ μλλ‘ νΈλμ§μ μ μ§ννλ€. |
ease |
μ²μμλ μ²μ²ν μμνκ³ μ μ λΉ¨λΌμ§λ€κ° λ§μ§λ§μλ μ²μ²ν λλΈλ€. |
ease-in |
μμμ λλ¦¬κ² νλ€. |
ease-out |
λλ¦¬κ² λλΈλ€. |
ease-in-out |
λλ¦¬κ² μμνκ³ λλ¦¬κ² λλΈλ€. |
cubic-bezier (n, n, n, n) |
λ² μ§μ ν¨μλ₯Ό μ§μ μ μν΄ μ¬μ©νλ€. nμμ μ¬μ©ν μ μλ κ°μ 0~1μ΄λ€. |
β
<style>
.ease {
-moz-transition: 3s ease;
-o-transition: 3s ease;
-webkit-transition: 3s ease;
transition: 3s ease; /* μ²μμλ μ²μ²ν μμνκ³ μ μ λΉ¨λΌμ§λ€κ° λ§μ§λ§μλ μ²μ²ν λλΈλ€ */
}
#ex .linear{
-webkit-transition: 3s linear;
-moz-transition: 3s linear;
-o-transition: 3s linear;
transition: 3s linear; /* μμλΆν° λκΉμ§ λκ°μ μλλ‘ νΈλμ§μ
μ μ§ν */
}
#ex .ease-in{
-webkit-transition: 3s ease-in;
-moz-transition: 3s ease-in;
-o-transition: 3s ease-in;
transition: 3s ease-in; /* μμμ λλ¦¬κ² νλ€ */
}
#ex .ease-out{
-webkit-transition: 3s ease-out;
-moz-transition: 3s ease-out;
-o-transition: 3s ease-out;
transition: 3s ease-out; /* λλ¦¬κ² λλΈλ€ */
}
#ex .ease-in-out{
-webkit-transition: 3s ease-in-out;
-moz-transition: 3s ease-in-out;
-o-transition: 3s ease-in-out;
transition: 3s ease-in-out; /* λλ¦¬κ² μμνκ³ λλ¦¬κ² λλΈλ€ */
}
</style>
<body>
<div id="ex">
<div class="ease"> ease </div>
<div class="linear"> linear </div>
<div class="ease-in"> ease-in </div>
<div class="ease-out"> ease-out </div>
<div class="ease-in-out"> ease-in-out </div>
</div>
</body>
β
*transition-delay μμ± - μ§μ° μκ° μ€μ νκΈ°
transition-delay μμ±μ νΈλμ§μ μ΄ μΈμ λΆν° μμν κ²μΈμ§λ₯Ό μ€μ νλ€. μ§μ νλ μκ°λ§νΌ κΈ°λ€λ Έλ€κ° νΈλμ§μ μ΄ μμλλ€. μ¬μ©ν μ μλ κ°μ μ΄(seconds)λ λ°λ¦¬μ΄(milliseconds)μ΄λ©° κΈ°λ³Έ κ°μ 0μ΄λ€.
β
κΈ°λ³Έν)
transition-delay: <μκ°> |
β
<style>
#no-delay {
-webkit-transition-duration: 3s;
-moz-transition-duration: 3s;
-o-transition-duration: 3s;
transition-duration: 3s;
border: 1px solid #ff6a00;
}
#delay {
-webkit-transition-duration: 3s;
-moz-transition-duration: 3s;
-o-transition-duration: 3s;
transition-duration: 3s;
-webkit-transition-delay: 1s;
-moz-transition-delay: 1s;
-o-transition-delay: 1s;
transition-delay: 1s;
border: 1px solid #006aff;
}
</style>
<body>
<div id="ex">
<div id="no-delay" class="box"> <p>no-delay</p> </div>
<div id="delay" class="box"> <p>delay</p> </div>
</div>
β
β
*transition μμ± - νΈλμ§μ μμ± νκΊΌλ²μ νκΈ°νκΈ°
κ° λΈλΌμ°μ μ λ§κ² μμ± μ΄λ¦ μμ μ λμ¬λ₯Ό λΆμ¬μΌ νλ€.
μμ€κ° μ무리 κΈΈμ΄μ§λλΌλ νΈλμ§μ μ μ© λμμ 2~3κ°μ© μΌλΆλ§ μ§μ ν κ²½μ°, transition-property μμ±μ μ΄μ©ν΄ λμμ μλ € μ£Όμ΄μΌ νκ³ κ° λμλ³λ‘ μ§ν μκ°μ΄ λ€λ₯΄λ€λ©΄ transition-duration μμ±μ μ΄μ©ν΄ μκ°λ λ°λ‘ μ§μ νλ κ²μ΄ μ’λ€. νμ§λ§ νΈλμ§μ μ μ© λμμ΄ μ 체μ΄κ³ νΈλμ§μ μ€ν μκ°μ΄ λμλ³λ‘ λ€λ₯΄μ§ μλ€λ©΄ transition μμ±μΌλ‘ νκΊΌλ²μ μ§μ νλ κ²μ΄ νΈλ¦¬νλ€.
β
κΈ°λ³Έν)
transition: <transition-property κ°> | <transition-duration κ°> | <transition-timing-function κ°> | <transition-delay κ°> |
<style>
.tr1 {
width: 200px;
height: 200px;
background-color: red;
border: 1px solid black;
-webkit-transition: 2s ease-in;
-moz-transition: 2s ease-in;
-o-transition: 2s ease-in;
transition: 2s ease-in;
}
.tr1:hover {
width: 100px;
height: 100px;
background-color: #ff6e5f;
-webkit-transform: rotate(270deg);
-moz-transform: rotate(270deg);
-o-transform: rotate(270deg);
-ms-transform: rotate(270deg);
transform: rotate(270deg);
}
</style>
</head>
β
<body>
<div class="tr1"></div>
</body>
'HTML5 & CSS3' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[HTML5 & CSS3] λͺ¨λ°μΌ κΈ°κΈ°μ μΉ λμμΈ (0) | 2021.02.14 |
---|---|
[HTML5 & CSS3] μ λλ©μ΄μ (0) | 2021.02.14 |
[HTML5 & CSS3] λ³νκ³Ό κ΄λ ¨λ μμ±λ€ (0) | 2021.02.14 |
[HTML5 & CSS3] λ³ν (0) | 2021.02.14 |
[HTML5 & CSS3] κ°μ ν΄λμ€μ κ°μ μμ (0) | 2021.02.14 |
λκΈ