HELP: Create Movement Using CSS Animation (offset property)

HELP: Create Movement Using CSS Animation (offset property)
0

#1

Tell us what’s happening:
Hello, I’m afraid that I’m quite stuck on this particular task! We are instructed as follows:

Add a horizontal motion to the div animation. Using the left offset property, add to the @keyframes rule so rainbow starts at 0 pixels at 0%, moves to 25 pixels at 50%, and ends at -25 pixels at 100%. Don’t replace the top property in the editor - the animation should have both vertical and horizontal motion.

And I can’t quite see what’s wrong with my code. I should be grateful if anyone could point it out to me. Thanks!
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 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.2 Safari/605.1.15.

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


#2

I FIGURED IT OUT! Ha. I was quite silly and removed the ‘top’, which it explicitly stated NOT to do. Brilliant lol.:roll_eyes::joy:


#3

Thanks. I didn’t read the challenge description correctly.