transition: {property} {duration} + {Event}
# html
<button>Click!</button>
# css
<style>
button {
padding: 1rem;
font-size: 2rem;
color: white;
background: pink;
transition: padding 2s;
}
button:hover {
padding: 2rem;
}
</style>
transition만의 속성들:
- transform: ... 단축 속성(축약형)으로도 사용 가능
- transform-origin: numX, numY;
- duration: step-end, steps(num)
animation: {name} {duration} + @keyframes {name} {...}
animation: name duration timing-function delay iteration-count direction fill-mode;
# html
<div>
<button>Click!</button>
</div>
# css
<style>
button {
padding: 1rem;
font-size: 2rem;
color: white;
background: pink;
transition: padding 2s ease-in-out;
}
button:hover {
padding: 2rem;
}
</style>
@keyframs name {...}
from
은 0%, to
는 100%를 나타낸다.@keyframes bounce {
60%, 80%, to { transform: translateY(350px); }
70% { transform: translateY(250px); }
90% { transform: translateY(300px); }
}
.ball {
animation: bounce 1s ease-in forwards;
}
@keyframes bounce {
60%, 80%, to {
transform: translateY(350px);
animation-timing-function: ease-out;
}
70% { transform: translateY(250px); }
90% { transform: translateY(300px); }
}
Google 개발자 툴에서 animation속성을 찾아서 📈그래프 아이콘을 클릭!!!
- ease-in:
- ease-out:
- ease-in-out:
- cubic-bazier( x1, y1, x2, y2 )
animation: name duration timing-function delay iteration-count direction fill-mode;
background-size: 120%;
대신 transform: scale(120%);
를 사용하면 해결!!!