snippetcssTip
CSS Button Transitions
Viewed 0 times
transitionsbuttoncss
Problem
CSS transitions are a great way to add some life to your buttons. From growing and shrinking, to fill, swing and border animations, there are many ways to make your buttons more interactive.
https://codepen.io/chalarangelo/pen/qBedyER
To create a grow animation on hover, you can use an appropriate
> [!TIP]
>
https://codepen.io/chalarangelo/pen/qBedyER
To create a grow animation on hover, you can use an appropriate
transition to animate changes to the element. Use the :hover pseudo-class to change the transform to scale(1.1), growing the element when the user hovers over it.> [!TIP]
>
Solution
.button-grow {
transition: all 0.3s ease-in-out;
}
.button-grow:hover {
transform: scale(1.1);
}To create a grow animation on hover, you can use an appropriate
transition to animate changes to the element. Use the :hover pseudo-class to change the transform to scale(1.1), growing the element when the user hovers over it.> [!TIP]
>
> You can also use the new
scale property to scale the element to a specific size. Simply replace transform: scale(1.1) with scale: 110%.Similarly, you can create a shrink animation on hover by using an appropriate
transition to animate changes to the element. Use the :hover pseudo-class to change the transform to scale(0.8), shrinking the element when the user hovers over it.> [!TIP]
Code Snippets
.button-grow {
transition: all 0.3s ease-in-out;
}
.button-grow:hover {
transform: scale(1.1);
}.button-shrink {
transition: all 0.3s ease-in-out;
}
.button-shrink:hover {
transform: scale(0.8);
}.button-fill {
background: #fff;
color: #000;
transition: all 0.3s ease-in-out;
}
.button-fill:hover {
background: #000;
color: #fff;
}Context
From 30-seconds-of-code: button-hover-transitions
Revisions (0)
No revisions yet.