웹프로그래밍 CSS3/CSS전환 & 변환
전환과 변환 2
별초롱언니
2025. 3. 15. 23:53
▣ 변화 속성
· transition-property : 변화 효과를 적용할 속성들 나열
· transition-duration : 변화가 지속되는 시간 지정
· transition-timing-function : 변화의 시작과 끝 타이밍 지정
· transition-delay : 변화 효과가 지연되는 시간 지정
▣ 변화 속성 작성 방식
· 단축형
div { transition : property duration timing-function delay;}
· 기본형
div {
transition : background 2s ease 1s,
padding 1s linear 2s;
}
· 확장기본형
div {
transition-property : width, height, border-width, color;
transition-duration: 1s, 2s, 1s, 3s;
transition-timing-function: ease, ease-in, ease-out, linear;
transition-delay: 3s, 1s, 1s, 2s;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div {
width: 100px;
height: 100px;
background-color: orange;
transition-property: width, background-color, color;
}
div:hover {
width: 400px;
background-color: brown;
color: white;
}
</style>
</head>
<body>
<div>마우스를 올리면 여러 속성이 변합니다. </div>
</body>
</html>
See the Pen Untitled by byeolchorong (@byeolchorong) on CodePen.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
div {
width: 280px;
height: 100px;
background-color: pink;
transition: background-color;
transition-duration: 10s;
text-align: center;
padding-top: 50px;
}
div:hover {
background-color: yellow;
}
</style>
</head>
<body>
<div>색상이 10초동안
<br>서서히 변하는중입니당</div>
</body>
</html>
See the Pen Untitled by byeolchorong (@byeolchorong) on CodePen.