I’m trying to animate a div on hover using CSS3’s @keyframes rule. The code for the animation is at the very bottom of this page (right after the generously marked “HERE BE ANIMATION” comment ASCII art). That includes the @keyframes rule, the div, and the div:hover. The page where I wanted this animation is right here. For some reason, the animation doesn’t work; this is the first time I’ve tried using CSS animation, so there’s probably some novice mistake somewhere.
Share
If you are trying to animate your div from 0px to 200px, it’s much more easier to use jQuery solution.
jQuery offers cross-browser compatibility compare to @keyframe, which is only supported in Safari and Chrome.
Here is an example: http://jsfiddle.net/ZgcxL/
EDIT:
If you don’t want your users to be limited only to Chrome and Safari, you should definitely consider jQuery. It’s very simple to use. Just add this code somewhere between your
<head></head>tags.EDIT 2:
I forgot document.ready(). Re-paste the code above.
Also add position: absolute; to your div and add ‘px’ to your width:
Tested, working.