[英]Rotate Text with Javascript
任何人都可以建議一種在不使用 Flash 或 Silverlight 之類的東西的情況下以任何角度旋轉文本的方法。 我想使用帶有相同角度的文本的傾斜圖像。
有點晚了,但我已經寫了一些代碼來做到這一點。
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);
}
可以與常規對象或 JQuery 對象一起使用。 並存儲一個名為“旋轉”的屬性,為您提供它的當前旋轉值。
找到了這個 jQuery 庫jQueryRotate ,它對我很有用。 請注意,即使名稱非常相似,它也不是 poke 鏈接到的同一個庫。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.