javascript - CSS/jQuery animation not triggering -
i'm trying use animation, triggered changing class in jquery on page load. isn't doing anything. i'm unsure of going wrong, although i'm pretty sure it's wrong css. here's code:
<html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>page 2</title> <style type="text/css"> /* styles go here */ img {width:200px; height:100px; animation-name: widthchange; animation-duration: 3s;} .loaded {animation-name: widthchange; animation-duration: 3s;} p {text-align:center} button {margin:20px} @keyframes widthchange { {width: 200px;} {width: 400px;} } </style> <script src="http://code.jquery.com/jquery.min.js"></script> <script type="text/javascript"> $(function(){ // jquery methods go here... $(document).ready(function() { $('img').addclass("loaded"); }); }); /* additional javascript goes here */ </script> </head> <body> <img class = "image" src="elephant.jpg" alt="elephant"/> <p><button>button 1</button><button>button 2</button><button>button 3</button></p> </body> </html>
you try code supported browsers: fiddle
img { width:200px; height:100px; animation-name: widthchange; animation-duration: 3s; -webkit-animation-name: widthchange; -webkit-animation-duration: 3s; -moz-animation-name: widthchange; -moz-animation-duration: 3s; -0-animation-name: widthchange; -0-animation-duration: 3s; } p {text-align:center} button {margin:20px} @-webkit-keyframes widthchange { {width: 200px;} {width: 400px;} } @-o-keyframes widthchange { {width: 200px;} {width: 400px;} } @-moz-keyframes widthchange { {width: 200px;} {width: 400px;} } @keyframes widthchange { {width: 200px;} {width: 400px;} }
Comments
Post a Comment