What is a syntactically clean solution to run a chain of individual CSS3 transitions on a single element, one by one? An example:
- set left to 10px and opacity to 1 through 200ms
- set left to 30px through 500ms
- set left to 50px and opacity to 0 through 200ms
Can this be done without JavaScript? If not, how to code it cleanly with JavaScript?
I believe you want a CSS3 animation where you define the CSS styles at different points in the animation and the browser does the tweening for you. Here’s one description of it: http://css3.bradshawenterprises.com/animations/.
You will have to check on browser support for your targeted browsers.
Here’s a demo that works in Chrome. The animation is pure CSS3, I only use Javascript to initiate and reset the animation:
http://jsfiddle.net/jfriend00/fhemr/
The CSS could be modified to make it work in Firefox 5+ also.