① transitions : 엘리먼트의 두가지 상태 사이에 변화를 줄 수 있다
- transition-timing-function 종류
linear | 균일하게(가장 많이 사용) |
ease | 잠깐 느리게 빠르게 느리게(기본값) |
ease-in | 느리게 빠르게 |
ease-out | 빠르게 느리기 |
ease-in-out | 느리게 빠르게 느리게 |
- hover를 줄 때 사용하며, transitions은 hover가 아닌 곳에 넣어줘야 한다 (default)
- 의도에 따라 달라질 수 있다
ex1)
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>timing func</title>
<style>
ul {
padding: 0;
padding: 1rem;
}
li {
list-style: none;
}
.item {
background: gold;
width: 20%;
height: 100px;
line-height: 100px;
padding-left: 1rem;
transition: 1s;
margin-bottom: 20px;
}
ul:hover .item {
width: 100%;
}
ul li:nth-child(1) .item {
transition-timing-function: ease;
}
li:nth-child(2) .item {
transition-timing-function: linear;
}
li:nth-child(3) .item {
transition-timing-function: ease-in;
}
li:nth-child(4) .item {
transition-timing-function: ease-out;
}
li:nth-child(5) .item {
transition-timing-function: ease-in-out;
}
</style>
</head>
<body>
<ul>
<li>
<div class="item">
ease
</div>
</li>
<li>
<div class="item">
linear
</div>
</li>
<li>
<div class="item">
ease-in
</div>
</li>
<li>
<div class="item">
ease-out
</div>
</li>
<li>
<div class="item">
ease-in-out
</div>
</li>
</ul>
</body>
</html>
ex2)
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>usa-travel</title>
<style>
/* 전체적인 틀 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: #000;
}
#wrap {
text-align: center;
padding: 20px;
}
li {
list-style: none;
width: 300px;
margin: 0;
padding: 0;
}
/* haeder */
header {
color: gray;
}
/* section */
section {
margin-top: 20px;
width: 1000px;
border: 2px solid #ddd;
display: inline-block;
}
ul {
display: inline-block;
width: 100%;
font-size: 0;
padding: 20px;
}
li {
width: 50%;
display: inline-block;
font-size: 1rem;
padding: 10px;
}
img {
width: 100%;
display: inline-block;
/* margin-top: 30px;
margin-bottom: 30px;
margin: 10px; */
transition: all 0.5s;
}
ul li img:hover {
width: 600px;
}
</style>
</head>
<body>
<div id="wrap">
<header>
<div class="inner">
<h1>hover/zoom/transition</h1>
</div>
</header>
<section>
<ul>
<li>
<img src="img/hollywood.jpg" alt="">
</li>
<li>
<img src="img/los-angeles1.jpg" alt="">
</li>
<li>
<img src="img/los-angeles2.jpg" alt="">
</li>
<li>
<img src="img/manhattan.jpg" alt="">
</li>
</ul>
</section>
</div>
</body>
</html>
'웹 > CSS' 카테고리의 다른 글
[코딩 공부_43] transform - translate, scale, skew, rotate? (0) | 2021.04.02 |
---|---|
[코딩 공부_42] self-introduce 만들기_1 (0) | 2021.04.01 |
[코딩 공부_40] 음수마진(negative margin)에 대하여 (0) | 2021.03.29 |
[코딩 공부_39] 가상 요소 셀렉터 (0) | 2021.03.26 |
[코딩 공부_38] li 간격 없애는 방법 3가지 (0) | 2021.03.24 |
댓글