Rotate Text with Javascript
Can anyone suggest a way of rotating text by any angle without using something like Flash or Silverlight. I'd like to use a slanted image wi开发者_如何学编程th the text following the same angle.
It's a bit late, but I have written some code to do this.
http://jsfiddle.net/73DzT/139/
Object.prototype.rotate = function(d) {
var s = "rotate(" + d + "deg)";
if (this.style) { // regular DOM Object
this.style.MozTransform = s
this.style.WebkitTransform = s;
this.style.OTransform = s;
this.style.MSTransform = s;
this.style.transform = s;
} else if (this.css) { // JQuery Object
this.css("-moz-transform", s);
this.css("-webkit-transform", s);
this.css("-o-transform", s);
this.css("-ms-transform", s);
this.css("transform", s);
}
this.setAttribute("rotation", d);
}
can be used with regular objects or with JQuery objects. and stores an attribute called "rotation" to give you it's current rotation value.
http://code.google.com/p/jquery-rotate/
You can try css rotation too http://snook.ca/archives/html_and_css/css-text-rotation
Found this jQuery library jQueryRotate which has worked great for me. Notice that it's not the same library that poke linked to even though the name is very similar.
http://code.google.com/p/jqueryrotate/
精彩评论