So I’ve been trying to move the ball in a vertical manner but I don’t understand why the animation is getting skipped. All I see is the ball at initial position which skips to a new position at 60% and back to start but the transition movement effect is not taking place like it does with left to right and back
In the original problem of Left-Right transition If I use left: 60px; instead of % why does the ball go to the left from the initial position instead of going to right and coming back?
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0
Challenge: Create Visual Direction by Fading an Element from Left to Right
Hi, appreciate your explanation. I did get the px part. However, I don’t get why there needs to be an initial top value set in #ball? As in, in a previous problem the position of div was set to relative and it was possible to move the rectangle vertically without setting the top value in div. I’d really appreciate if you could elaborate a bit on that.
It doesn’t need to be set outside the keyframe (in #ball) but it does need to be set… In the link You provided the @keyframe has
0%{
top: (starting position)
}
50% {
top: (position at 50%)
}
100% {
top: (position at 100%)
}
So, in your link the start and end are set in the keyframe. My opinion only, the easiest to read is in the keyframe, but as these examples show the start/ end doesn’t have to be in the @keyframe.
I see. I get it now. I just tried that and was experimenting with what you suggested and found something unusual wrt the functionality of mentioning it inside the @keyframes or outside. In the example of my main post, adding the 0% frame only made it go down but it did not come back up.
However, if the top is declared in #ball, it comes back up even without 100% frame. So is this behavior normal?
That’s because you gave it a starting value, but it still does not have a ending value where you want it to go, so it stops after going down. You also need to add where it should be at 100%.
Yes, because the top position declared in #ball is the start and ending position.