This is an example of a simple CSS tricks that could produce a nice animation.
Basically, the trick is into adding a background using linear-gradient and changing its position on hover.
Let’s dive into it.
Let’s create a simple button first.
Add the background using linear-gradient.
Change the size of the background to 200%.
The overall background is doubled now and we can set the position of the background to right. If you want to create animation from right to left, set the background-position to left or change the linear-gradient.
Let’s also change the color of the button for better contarst.
Let’s set the background-position to right on hover.
Still we don’t see the animation. Do we?
At the end, all comes onto the transition property. Let’s add it. You can adjust the speed using the time in the transition property.
That’s it.
animation background button color examples