CLiown
CLiown

Reputation: 13843

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 with the text following the same angle.

Upvotes: 3

Views: 22352

Answers (4)

A. Tapper
A. Tapper

Reputation: 1271

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/

Upvotes: 0

rlemon
rlemon

Reputation: 17666

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.

Upvotes: 4

xuma
xuma

Reputation: 53

You can try css rotation too http://snook.ca/archives/html_and_css/css-text-rotation

Upvotes: 0

poke
poke

Reputation: 387707

http://code.google.com/p/jquery-rotate/

Upvotes: 3

Related Questions