CSS transition
- type
- property (shorthand)
- applies to
- any element with a property that changes
- inherits
- no
- common values
- opacity 0.2s ease, all 0.3s ease-in-out
Where it goes
On the tag in its normal state, not on the :hover rule.
Example
button {
opacity: 1;
transition: opacity 0.2s ease;
}
button:hover {
opacity: 0.8;
}Common mistakes
- Putting transition inside the :hover rule. Then it only glides on the way in. When the mouse leaves, it snaps back.
- Using transition: all as a catch-all. It can quietly animate things it should not, like layout sizes, and slow the page down.