Before we delve into the world of animation, here are a few tips to keep in mind:
No need to type out doctype
, head
, and body
tags as JSFiddle handles that for you.
Remember to escape characters like <
and >
with <
and >
to prevent breaking your HTML code.
When working on CSS3 animations, make sure to use Vendor Prefixes for better browser compatibility:
- Chrome & Safari: -webkit-
- Firefox: -moz-
- Opera: -o-
- Internet Explorer: -ms-
It's recommended to save non-prefixed CSS3 code for last as it will override any browser-specific prefixes. For keyframes, structure them like this example:
@-webkit-keyframes tutsFade { /* your style */ }
@-moz-keyframes tutsFade { /* your style */ }
@-ms-keyframes tutsFade { /* your style */ }
@-o-keyframes tutsFade { /* your style */ }
@keyframes tutsFade { /* your style */ }
Now onto the animation part - check out this simplified version of your example here. The .exampleAnimation
class includes everything needed for an element to start animating with the defined example
animation at the end of the CSS file. You can directly apply this class to an HTML element or manage it through JavaScript to control the animation playback.
For beginners, here are some beginner-friendly tutorials: Introduction to CSS Animation, and Control CSS3 Animations With jQuery.