μ ν?
- μμ(element)μ μμ±(property)μ΄ λ³κ²½λ λλΆλλ½κ²λ³κ²½λλ ν¨κ³Ό μ 곡
- μ) μμμ λ°°κ²½μμ΄ λ³κ²½λ λ λ°λ‘ λ³κ²½λλ κ²μ΄ μλλΌ μΌμ μκ°μ΄ μ§λλ©΄ μμν λ³κ²½λλ ν¨κ³Όλ₯Ό μ€ μ μμ΅λλ€.
μ ν ν¨κ³Όκ° μλ κ²½μ°
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.box1 {
width: 100px;
height: 100px;
background-color: red;
}
.box1:hover {
background-color: blue;
}
</style>
</head>
<body>
<div class="box1"></div>
</body>
</html>
λκ° νμ ν λλ.
μ ν ν¨κ³Ό μ μ©ν κ²½μ°
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.box1 {
width: 100px;
height: 100px;
background-color: red;
transition-property: all;
transition-duration: 1s;
transition-delay: .3s;
}
.box1:hover {
background-color: blue;
}
</style>
</head>
<body>
<div class="box1"></div>
</body>
</html>
μκΉλ³΄λ€ λΆλλ¬μ΄ λλ
νΈλμ§μ κ³Ό μμ±
- transition-property : νΈλμ§μ μ λμ μ§μ
- transition-duration : νΈλμ§μ μ μ€νν μκ° μ§μ
- transition-delay : νΈλμ§μ μ μ§μ° μκ° μ§μ
- transition-timing-function : νΈλμ§μ μ μ€ν νν μ§μ
- transition : μμ± νκΊΌλ²μ μ§μ
π μ ν ν¨κ³Όλ λ°λμ transition-property
μμ±κ³Ό transition-duration
μμ±μ ν¨κ» μ¬μ©ν΄μΌ ν¨.
transition-property μμ±
- νΈλμ§μ μ λμ μ§μ
transition-properry : [μμ±κ°];
- none : μ ν ν¨κ³Ό μμ±μ μ§μ νμ§ μμ΅λλ€.
- all : λͺ¨λ μμ±μ μ ν ν¨κ³Ό λμμΌλ‘ μ§μ ν©λλ€.
- κ°λ³μ μΌλ‘ μ§μ κ°λ₯ π
transition-duration μμ±
- νΈλμ§μ μ μ€νν μκ° μ§μ
transition-duration: [μκ°];
μ) transition-duration: 2s;
transition-delay μμ±
- νΈλμ§μ λ°μ μ§μ° μκ° μ§μ
transition-timing-function μμ±
- μ ν ν¨κ³Όμ μ§ν μλ μ§μ
- μ ν΄μ§ ν€μλμ cubic-bezier() ν¨μ(μ¬μ©μ μ§μ )μ μ¬μ©ν μ μμ΅λλ€.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body {
margin: 0 auto;
}
.red-box {
background-color: orangered;
width: 100px;
height: 100px;
transition: all;
transition-duration: 2s;
transition-delay: .3s;
margin-bottom: 10px;
}
.red-box:hover {
background-color: blue;
width: 800px;
}
.red-box:nth-child(1) {
transition-timing-function: linear;
}
.red-box:nth-child(2) {
transition-timing-function: ease;
}
.red-box:nth-child(3) {
transition-timing-function: ease-in;
}
.red-box:nth-child(4) {
transition-timing-function: ease-out;
}
.red-box:nth-child(5) {
transition-timing-function: ease-in-out;
}
</style>
</head>
<body>
<!-- μμμ μμ±μ΄ λ³κ²½λ λ 'λΆλλ½κ²' λ³κ²½λλ ν¨κ³Ό μ 곡(μκ°μ΄ κ°μ
λ¨) -->
<div class="red-box">liner</div>
<div class="red-box">ease</div>
<div class="red-box">ease-in</div>
<div class="red-box">ease-out</div>
<div class="red-box">ease-in-out</div>
</body>
</html>
ν¬λ‘¬ κ°λ°μ λꡬμμλ νμΈ κ°λ₯
transition μμ±μΌλ‘ νλ²μ μ§μ νκΈ°
κΈ°λ³Έ νν)
transition: property, duration, timing-function, delay;
μμ)
transition:width, 1s, ease-in, 1s;
μ€μ΅ μμ - μν μ 보 νμνκΈ°
- ν΄λΉ μνμ λ§μ°μ€ μ€λ²μ μν μ 보 νμ νκΈ°
- νΈλμ§μ ν¨κ³Ό μ μ©νκΈ°
- μν 1, μν 2, μν 3 νμ΄νλ§ λ€λ₯΄κ³ λ΄μ©μ λμΌνκ²
- opacity: 0; μ΄λ©΄ νλ©΄μ 보μ΄μ§ μμ(ν¬λͺ λλ₯Ό μ‘°μ νλ μμ±)
μ½λ
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>μ μν λͺ©λ‘</title>
<style>
#container {
width: 1000px;
margin: 20px auto;
}
h1 {
text-align: center;
font-size: 30px;
}
ul {
list-style: none;
padding: 0;
}
li {
float: left;
padding: 0px;
margin: 10px;
position: relative;
overflow: hidden;
}
img {
margin: 0px;
padding: 0px;
z-index: 5;
float: left;
}
li .caption {
position: absolute;
left: -200px;
width: 300px;
height: 200px;
padding-top: 20px;
background-color: rgba(0, 0, 0, .6);
opacity: 0;
transition: .8s .2s ease-in-out;
z-index: 10;
}
li:hover .caption {
opacity: 1;
transform: translateX(200px);
}
.caption h2, .caption p {
color: white;
text-align: center;
}
</style>
</head>
<body>
<div id="container">
<h1>μ μν λͺ©λ‘</h1>
<ul>
<li>
<img src="./images/prod1.jpg" alt="μν1">
<div class="caption">
<h2>μν1</h2>
<p>μν1μ λν μ€λͺ
ν
μ€νΈ</p>
<p>κ°κ²© : 12,500μ</p>
</div>
</li>
<li>
<img src="./images/prod2.jpg" alt="μν2">
<div class="caption">
<h2>μν2</h2>
<p>μν2μ λν μ€λͺ
ν
μ€νΈ</p>
<p>κ°κ²© : 20,900μ</p>
</div>
</li>
<li>
<img src="./images/prod3.jpg" alt="μν3">
<div class="caption">
<h2>μν3</h2>
<p>μν3μ λν μ€λͺ
ν
μ€νΈ</p>
<p>κ°κ²© : 9,000μ</p>
</div>
</li>
</ul>
</div>
</body>
</html>
'π¨ Frontend > HTML & CSS' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
CSS β£ μ ν ν¨κ³Ό - (3) λ³ν ν¨κ³Ό(transform) (0) | 2023.03.16 |
---|---|
CSS β£ μ ν ν¨κ³Ό - (2) μ λλ©μ΄μ μμ± (2) | 2023.03.15 |
CSS β β’ νμ μμ± - (3) μ°μ΅ λ¬Έμ (2) | 2023.03.15 |
CSS β β’ νμ μμ± - (2) νλ©΄ λ°°μΉ (1) | 2023.03.15 |
CSS β β’ νμ μμ± - (1) ν μ€νΈ, λ°μ€ λͺ¨λΈ μμ± (0) | 2023.03.14 |