Animation colour change of a button upon hovering (colour keeps changing back)

Hey guys,

I’m on the challenge of changing the colour of a button upon hovering over it through animation. I know it’s not part of the challenge but when I hover over the button the animation completes and when it’s changed colour if I continue to hover over the button it then changes back to what it was.

Earlier I tried adding a different background colour after inclusion of the animation…
" button:hover {
animation-name: background-color;
animation-duration: 500ms;
background-color: #4791d0;
} "

Of course this wasn’t the answer and simply changed colour (while completely skipping the animation).

Here’s my current attempt with some obscure (and probably incorrect) attempt at a “::after” pseudo element, which is doing nothing. Any thoughts/help understanding what I’m doing wrong would be mega appreciated!

Your code so far

  button {
    border-radius: 5px;
    color: white;
    background-color: #0F5897;
    padding: 5px 10px 8px 10px;
  button:hover {
    animation-name: background-color;
    animation-duration: 500ms;

  @keyframes background-color{

  button:hover::after {

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36.

Link to the challenge:

The next challenge explain it so …:rofl:

1 Like

Well, just go to the next challenge! :slight_smile:
But it’s a good thing taht you ask yourself why it does that! Congrats :wink:

1 Like