That's great, but it doesn't work right yet. Notice how the animation resets after500mshas passed, causing the button to revert back to the original color. You want the button to stay highlighted.
This can be done by setting theanimation-fill-modeproperty toforwards. Theanimation-fill-modespecifies the style applied to an element when the animation has finished. You can set it like so:
animation-fill-mode: forwards;
Set theanimation-fill-modeproperty ofbutton:hovertoforwardsso the button stays highlighted when a user hovers over it.
<style>button {
border-radius: 5px;
color: white;
background-color: #0F5897;
padding: 5px10px8px10px;
}
button:hover {
animation-name: background-color;
animation-duration: 500ms;
/* Only change code below this line */animation-fill-mode: forwards;
/* Only change code above this line */
}
@keyframes background-color {
100% {
background-color: #4791d0;
}
}
</style><button>Register</button>