전환은 element가 조건에 따라 변화할 때 어떤 element를 변화시킬지, 어떻게 변화시킬지를 설정하는 기능이다.
<!doctype html>
<html>
<head>
<style>
#test{
font-size: 3rem;
display : inline-block;
transition-property: all;
transition-duration: 1s;
transition-delay: 0.5s;
transition-timing-function: linear;
}
#test:hover{
transform : translate(20px,20px);
font-size : 2rem;
}
</style>
</head>
<body>
<div id="test"> hello </div>
</body>
</html>
<!doctype html>
<html>
<head>
<style>
body{
background-color: powderblue;
transition : all 2s;
}
div{
background-color: powderblue;
color: white;
width: 400px;
height: 200px;
font-size: 2rem;
text-align: center;
padding: 10px;
}
</style>
</head>
<body onload="document.querySelector('body').style.backgroundColor='white';">
<div>transition</div>
</body>
</html>