Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I rotate an image in Javascript or CSS

I am creating a simple game.

I want to use jQUERY to rotate the joints making it move. I am using .animate ( http://api.jquery.com/animate/ ) to animate CSS properties but if it is also possible to use Javscript, I can make my own custom code.

More TO-THE-POINT

How do I rotate images in CSS or Javascript? I prefer CSS but Javascript is fine too.

If it is impossible (which I am pretty sure it is but I am not giving up yet) is there any other possible way to do what i am trying to do without making a bunch of seperate images, each rotated a different way. Or can anyone at least give me an example of a site that does something similar.

EDIT: I need 1 CSS property (no -something: rotation(500deg);) that works with FireFox, Safari and Chrome because those are the only browsers I really work with.

like image 753
Eric Avatar asked Jan 23 '23 12:01

Eric


1 Answers

Firefox and the Webkit browsers support a "transform" CSS property ("-webkit-transform", "-moz-transform"). Those can do all sorts of interesting things. There's a very weak IE tool that allows very limited rotation, so it's not really an option for something like a game.

Here's a demo page I made for another Stackoverflow question a few days ago: http://gutfullofbeer.net/compass.html

like image 83
Pointy Avatar answered Jan 25 '23 01:01

Pointy