Trouble with Use CSS Animation to Change the Hover State of a Button

Tell us what’s happening:

I cannot get it passed. Help, please

Your code so far


<style>
  button {
    border-radius: 5px;
    color: white;
    background-color: #0F5897;
    padding: 5px 10px 8px 10px;
  }
  
  button:hover {
    animation-name: background-color;
    animation-duration: 500ms;
    background-color: #4791d0;
  }
  @keyframes{
      100%{
      background-color: #4791d0;
      }
  }

</style>
  
<button>Register</button>

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0.

Link to the challenge:
https://learn.freecodecamp.org/responsive-web-design/applied-visual-design/use-css-animation-to-change-the-hover-state-of-a-button/

That was close!

Just give it a value of the animation-name property defined in button:hover selector to @keyframes

shimphillip. Got no clue.

The animation-name is background-color so you want your @keyframes to refer to the value of the animation-name so have the style be effective. If you still don’t get it after trying, here is the solution.

@keyframes background-color{
100%{
background-color: #4791d0;
}
}

1 Like

I think you can also use transition-duration for a simple animation like this, but it definitely can’t hurt to know how animations work.

Thank you. I had a duh moment.

Thank you this have solved it