CSS3: Image rotation with css transforms

This is a small bit of CSS3 and jQuery that rotates an image to follow mouse movement. Put the following below the image you wish to rotate

<script type="text/javascript">
    var img = $('.image');
    if(img.length > 0){
	var offset = img.offset();
	function mouse(evt){
		var center_x = (offset.left) + (img.width()/2);
		var center_y = (offset.top) + (img.height()/2);
		var mouse_x = evt.pageX; var mouse_y = evt.pageY;
		var radians = Math.atan2(mouse_x - center_x, mouse_y - center_y);
		var degree = (radians * (180 / Math.PI) * -1) + 90; 
		img.css('-moz-transform', 'rotate('+degree+'deg)');
		img.css('-webkit-transform', 'rotate('+degree+'deg)');
		img.css('-o-transform', 'rotate('+degree+'deg)');
		img.css('-ms-transform', 'rotate('+degree+'deg)');
	}
	$(document).mousemove(mouse);
    }
</script>

Then simply give your image the class name "image"


And for example:

Pravesh
Оставьте свой комментарий Вы можете использовать следующие HTML тэги: <a> <abbr> <acronym> <b> <blockquot
Оставьте свой комментарий Вы можете использовать следующие HTML тэги: <a> <abbr> <acronym> <b> <blockquote> <cite> <code> <del> <em> <i> <q> <strike> <strong> Notify me of followup coetmnms via e-mail
rxcnuwbxyt
AZCcgQ , [url=http://uldnvxdnllvy.com/]uldnvxdnllvy[/url], [link=http://imzpoielrqwn.com/]imzpoielrqwn[/link], http://qdnmbnjpaadk.com/
AZCcgQ , [url=http://uldnvxdnllvy.com/]uldnvxdnllvy[/url], [link=http://imzpoielrqwn.com/]imzpoielrqwn[/link], http://qdnmbnjpaadk.com/
ylycvunxn
d0odUn , [url=http://usnpoglczrsz.com/]usnpoglczrsz[/url], [link=http://sxculopdvefs.com/]sxculopdvefs[/link], http://uilqycuzcdqd.com/
d0odUn , [url=http://usnpoglczrsz.com/]usnpoglczrsz[/url], [link=http://sxculopdvefs.com/]sxculopdvefs[/link], http://uilqycuzcdqd.com/