What is wrong with this CSS3 code, it won't animate in Google Chrome, why?
|
05-05-2014, 08:37 AM
Post: #1
|
|||
|
|||
What is wrong with this CSS3 code, it won't animate in Google Chrome, why?
<!DOCTYPE html>
<html> <head> <style type="text/css"> .twitter-bird { background-image: url (http://minimalmonkey.com/lab/css3- animations/twitter-bird-sprite.png); display: inline-block; height: 150px; width: 150px; } .twitter-bird:hover { animation: fly 0.2s steps(3) 0 infinite; } @keyframes fly { from { background-position: 0 0; } to { background-position: -450px 0; } } </style> </head> <body> <div class="twitter-bird"> </div> </body> </html> Ads |
|||
05-05-2014, 08:49 AM
Post: #2
|
|||
|
|||
For Google Chrome, need to specify "-webkit-" as prefix for both keyframes and animations. It does not support in Firefox also. because you are using background-position when hovering the twitter-bird.
Try this code: <!DOCTYPE html> <html> <head> <style type="text/css"> .twitter-bird { background-image:url(http://minimalmonkey.com/lab/css3-animat...rite.png); display: inline-block; height: 150px; width: 150px; } @keyframes fly { from { background-position: 0 0; } to { background-position: -450px 0;} } @-webkit-keyframes fly { from { background-position: 0 0; } to { background-position: -450px 0;} } .twitter-bird:hover { animation: fly 0.2s steps(3) 0 infinite; -webkit-animation: fly 0.2s steps(3) 0 infinite; } </style> </head> <body> <div class="twitter-bird"> </div> </body> </html> Ads |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)