Create Movement Using CSS Animation-am I still off?

Create Movement Using CSS Animation-am I still off?
0

#1

what am I missing here? says to keep top, I have all the numbers correct. But it says I’m wrong still. Forums give say I’m correct but it’s not passing it. Am I still wrong?


<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;
    top: 0px;
    
  }
  50% {
    background-color: green;
    top: 25px;
    
  }
  100% {
    background-color: yellow;
    top: -25px;
    
  }
}
</style>

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

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


#2

According to the instructions, you were not supposed to change the existing top offset property, but you did. Also, the instructions tell you to add a left offset property with applicable value for each animation step, but you did not do that.

I suggest resetting the code and try again.


#3

you are adjusting the “top” rule. You should add a “left” rule to each frame with the given pixel values and leave the “top” rule as is.

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

#4

ohhhhhhh! ok, I think I understand now! Taking another go. :slight_smile:


#5

I tried this as well but it kept failing me, not sure what I was doing wrong as it could be as simple as forgetting the ;
This finally worked but with 50% top still at 50px and then left 25px

Thank you for the help!


#6

Thank you for the oppertunity