I wanting to animate one element then another then another, is this possible with CSS? I can't seem to get it working, here is my attempt so far. I have two major problems:
1) My animation does not happen.
2) When it does happen, it will animate each element at the same time, what I wanting is animate the next element when the last has finished. Does CSS have this kind of capability yet?
3) I want it to be infinite.
I think I have name 3, but my animation wont play so I cannot test it. I am trying to make a loading animation, ideally I dont want to use JS as I assume this would be bad practice?
I know this is old ticket, but I hope my answer may help someone.
If you are okay to use css plugin then use this: https://daneden.github.io/animate.css/
Keep handy custom CSS for delay and use accordingly like this:
HTML should look something like this:
Here is few additional control to use with animation.css
Note: be sure to replace "vendor" in the CSS with the applicable vendor prefixes (webkit, moz, etc)
For more documentation you can refer here: https://github.com/daneden/animate.css/
Since you have the jQuery tag on the question I'm providing a jQuery approach. I think it is cleaner if you want infinite approach. Here's the fiddle.
I added display:none; to your e class:
And use an Immediately Invoked Function Expression (IIFE) to process the collection of elements supplied by the jQuery selector
$('.e')
.Edit in response to comment:
Be careful with infinite. You probably want to add a clearTimout() call you stop execution after you deem it is no longer necessary. Here is the updated js code (updated fiddle):
You need to add different
animation-delay
to all elements.Demo using
animation-direction: alternate
---> jsbin