Create Movement Using CSS Animation

Tell us what’s happening:
I don’t know what a heck am I doing wrong here! it wanted me to change the left-offset on the @keyframes at the 0 %, 50 % and 100 %. Maybe its brain overload maybe I am blind, but could anyone please help here, I am actually stuck here :disappointed_relieved:

Your code so far


<style>
  div {
    height: 40px;
    width: 70%;
    background: black;
    margin: 50px auto;
    border-radius: 5px;
    position: relative;
  }

#rect {
  animation-name: rainbow;
  animation-duration: 4s;
}

@keyframes rainbow {
  0% {
    background-color: blue;
    left: 0px;
    
  }
  50% {
    background-color: green;
    left: 25px;
    
  }
  100% {
    background-color: yellow;
    left: -25px;
    
  }
}
</style>

<div id="rect"></div>

Your browser information:

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

Link to the challenge:
https://learn.freecodecamp.org/responsive-web-design/applied-visual-design/create-movement-using-css-animation

The top properties in the keyframes should be kept intact.

1 Like

I have a similar problem and unlike you i did not change top. It still does not pass.
Here is mine. I don’t understand what is wrong.

div {
    height: 40px;
    width: 70%;
    background: black;
    margin: 50px auto;
    border-radius: 5px;
    position: relative;
  }

#rect {
  animation-name: rainbow;
  animation-duration: 4s;
}

@keyframes rainbow {
  0% {
    background-color: blue;
    top: 0px;
    left: 0px;
  }
  50% {
    background-color: green;
    top: 25px;
    left: 25px;
  }
  100% {
    background-color: yellow;
    top: -25px;
    left: -25px;
  }
}

The three top properties should be 0px, 50px and 0px in that order.

4 Likes

Wow… thank you! it worked… I did not understand that from what they wanted me to do. It said - “Don’t replace the top property in the editor”, so I did not touch it!

Read - Search - Ask --> Thanks to you guys asking I didn’t have to get passed the read and search part of the problem with this exercise. I also deleted the top values and replaced them with the left values.

Small misunderstandings by reading small words as ‘add’ wrong. I read ‘replace’. Besides I didn’t read the ‘don’t replace…(…)…’ part at all … God knows why …

1 Like


This work.

Do not change the top values and add the left offset values just as written in the scenario.

It works! Thank You!

@keyframes rainbow {
  0% {
    background-color: blue;
    top: 0px;
    left:0px;
  }
  50% {
    background-color: green;
    top: 50px;
    left:25px;
  }
  100% {
    background-color: yellow;
    top: 0px;
    left:-25px;
  }