+ 3

I've got stuck with @keyframes in animation. Please help me out!

I've created a simple animation to move an object from one position to another and I created the keyframes like @keyframes drive{ from{ transform:translateX(0px);} to {transform:translateX(300px);} } but when I run this, the object , after defined delay, appears at the final position without showing the movement. Please find it here. Thank you! https://code.sololearn.com/Wyw2sWO1zzCx/?ref=app

25th Feb 2018, 7:09 AM
Шащи Ранжан
Шащи Ранжан - avatar
11 Answers
+ 12
It seems you've forgot to define the animation-duration for the mario class. Just provide any value like 3s and you're good to go! 😉
25th Feb 2018, 7:32 AM
Zephyr Koo
Zephyr Koo - avatar
+ 7
Hi Shashi Ranjan! In CSS, animation property requires a duration attribute which sets the time-interval of the same. As the default value of animation-duration is 0s, therefore your animation just flashed-off. To make it flow, you require: animation-duration: 5s; // inside the .mario block Hope it does the part!
25th Feb 2018, 7:37 AM
777
777 - avatar
+ 7
You're welcome! Every hardwork you've done will push you to the next level, so believe in yourself! 👍
27th Feb 2018, 2:17 PM
Zephyr Koo
Zephyr Koo - avatar
+ 6
@Shashi Ranjan Yup it's really cool when I first saw the Mario character in you code, the parallax effect is great! Now you've to think how to repeat the animation so it appears to be travelling forever. 😉
25th Feb 2018, 11:52 PM
Zephyr Koo
Zephyr Koo - avatar
+ 6
Well all you need is adding the following property to the mario class:- animation-iteration-count: infinite; and try to understand why it works. Of course, the more practices you got, the better you become. Can't wait to see your next masterpiece! 😉
27th Feb 2018, 1:28 PM
Zephyr Koo
Zephyr Koo - avatar
+ 5
@Shashi Ranjan You're welcome! 😉
25th Feb 2018, 3:54 PM
Zephyr Koo
Zephyr Koo - avatar
+ 3
Yea, I tried but you know, by doing so, some other parameters get disturbed so I restored it to previous version. Btw, I'll work upon that. thank you for the help. 😄 And Masterpiece...?? Hahaha😂 That's too much for me, at least for now😉😂
27th Feb 2018, 1:54 PM
Шащи Ранжан
Шащи Ранжан - avatar
+ 2
oh...yes! How can I...? Lol😂 Thank you soo much Zephyr for your input. I thought that animation-delay is enough. It's my first animation and I was worried about it since last night. Thanks again buddy!😀
25th Feb 2018, 7:38 AM
Шащи Ранжан
Шащи Ранжан - avatar
+ 2
Thanks to you too Blue!😀 Now it worked! I'm glad.
25th Feb 2018, 7:39 AM
Шащи Ранжан
Шащи Ранжан - avatar
+ 2
Zephyr...did you see my animation now? See it once, I've created it quite nice...Lol😉
25th Feb 2018, 5:48 PM
Шащи Ранжан
Шащи Ранжан - avatar
+ 2
@Zephyr Koo yep thinks! And what repeat? You mean should I set it to infinite? I tried but in @keyframes drive{} it's not working with X from -200px or something. By default it's starting every time with X from 0px. I don't know why it's happening. I guess, due to device?
26th Feb 2018, 2:57 AM
Шащи Ранжан
Шащи Ранжан - avatar