導航:首頁 > 動漫圖片 > js怎麼旋轉圖片

js怎麼旋轉圖片

發布時間:2022-07-22 04:09:09

⑴ js代碼怎麼讓一張圖片自動360度水平旋轉

<!DOCTYPEHTML>
<html>
<head>
<metacharset=UTF-8>
<title>YuGiOh</title>
<styletype="text/css">
#div{
position:absolute;
top:50px;
left:300px;
width:300px;
height:300px;
line-height:300px;
text-align:center;
border:1pxsolidblack;
}
</style>
<scripttype="text/javascript">
varrotateHTML5=function(limit)
{
varreg=/(rotate([-+]?((d+)(deg))))/i;
varwt=div.style['-webkit-transform'],wts=wt.match(reg);
var$2=RegExp.$2;
console.log($2);
div.style['-webkit-transform']=wt.replace($2,parseFloat(RegExp.$3)+limit+RegExp.$4);
}

varrotateIE=function(obj)
{
vard=!!obj.d?obj.d:1;
varr=d*Math.PI/180;
costheta=Math.cos(r);
sintheta=Math.sin(r);
obj.style.filter="progid:DXImageTransform.Microsoft.Matrix()";
varitem=obj.filters.item(0);
varwidth=obj.clientWidth;
varheight=obj.clientHeight;
item.DX=-width/2*costheta+height/2*sintheta+width/2;
item.DY=-width/2*sintheta-height/2*costheta+height/2;
item.M11=costheta;
item.M12=-sintheta;
item.M21=sintheta;
item.M22=costheta;
obj.timer=setTimeout(function()
{
vardx=d+1;
dx=dx>360?1:dx;
obj.d=dx;
rotate(obj,dx);
},30);
};

varstart=function()
{
if(!!div.interval)
{
clearInterval(div.interval);
deletediv.interval;
}
else
{
div.interval=setInterval(function()
{
/.*webkit.*/i.test(navigator.userAgent)?rotateHTML5(1):rotateIE(div);
},30);
}
}
</script>
</head>
<body>
<buttononclick="start();">rotate</button>
<divid="div"style="border-radius:90px;-webkit-transform:rotate(10deg);">ROTATE</div>
</body>
</html>

⑵ javascript怎麼能旋轉圖片任意角度

文件---打開,找到你要編輯的圖片
打開以後呢,
再點
修改----變形---數字變形---下拉菜單選」旋轉」,輸入你想要的角度,保存就可以了..
但是這樣,圖片的突出部分會消失,如果你不想它消失的話,點
修改----畫布---符合畫布

⑶ 怎樣用js控制rotate使得一張圖片一直旋轉 點擊停止就暫停

js裡面有一個東西叫定時器,用起來是setinterval(方法明,心跳);
你寫個方法一直改變divrotate,點擊停止方法就好了。

⑷ Javascript如何改變圖片的方向

旋轉:

div
{
transform:rotate(45deg);
-ms-transform:rotate(45deg); /*IE9*/
-moz-transform:rotate(45deg); /*Firefox*/
-webkit-transform:rotate(45deg);/*Safari和Chrome*/
-o-transform:rotate(45deg); /*Opera*/
}

⑸ 用JS怎麼做旋轉相冊

下面是用css旋轉圖片,用js換className。

換圖片地址後試試。


<!doctypehtml>
<html>
<head>
<style>
.css-turn-0{
-moz-transform:matrix(1,0,0,1,0,0);
-o-transform:matrix(1,0,0,1,0,0);
-webkit-transform:matrix(1,0,0,1,0,0);
transform:matrix(1,0,0,1,0,0);
-ms-filter:"progid:DXImageTransform.Microsoft.Matrix(M11=1,M12=0,M21=0,M22=1,SizingMethod='autoexpand')"
}
.css-turn-270{
-moz-transform:matrix(0,-1,1,0,0,0);
-o-transform:matrix(0,-1,1,0,0,0);
-webkit-transform:matrix(0,-1,1,0,0,0);
transform:matrix(0,-1,1,0,0,0);
-ms-filter:"progid:DXImageTransform.Microsoft.Matrix(M11=0,M12=1,M21=-1,M22=0,SizingMethod='autoexpand')"
}
.css-turn-180{
-moz-transform:matrix(-1,0,0,-1,0,0);
-o-transform:matrix(-1,0,0,-1,0,0);
-webkit-transform:matrix(-1,0,0,-1,0,0);
transform:matrix(-1,0,0,-1,0,0);
-ms-filter:"progid:DXImageTransform.Microsoft.Matrix(M11=-1,M12=0,M21=0,M22=-1,SizingMethod='autoexpand')"
}
.css-turn-90{
-moz-transform:matrix(0,1,-1,0,0,0);
-o-transform:matrix(0,1,-1,0,0,0);
-webkit-transform:matrix(0,1,-1,0,0,0);
transform:matrix(0,1,-1,0,0,0);
-ms-filter:"progid:DXImageTransform.Microsoft.Matrix(M11=0,M12=-1,M21=1,M22=0,SizingMethod='autoexpand')"
}
</style>
</head>
<body>
<imgsrc="圖片地址">
<script>
varimg=document.getElementsByTagName('img')[0],
i=1,
css=['css-turn-0','css-turn-90','css-turn-180','css-turn-270'];

img.onclick=function(){
this.className=css[i++%4];
}
</script>
</body>
</html>

⑹ js設置圖片隨機旋轉角度

代碼應該是:
imgcss[i].style.transform="rotate(" + j + ")";
首先 j是變數 雙引號裡面套單引號 還是字元串, 不是變數

其次 字元串拼接要寫加號

⑺ js 怎麼實現點擊一次圖片旋轉90度,再點擊再轉90度呢

現在我們以這個蘋果的圖片作為例子

⑻ javascript如何實現圖片任意角度的旋轉

可以用JAvascript改變這個圖片的css來旋轉他:
這個是css代碼:
img {
transform:rotate(7deg);
-ms-transform:rotate(7deg); /* IE 9 */
-moz-transform:rotate(7deg); /* Firefox */
-webkit-transform:rotate(7deg); /* Safari 和 Chrome */
-o-transform:rotate(7deg); /* Opera */
}

在JAvascript裡面可以先獲取到這張圖片 設置圖片id = "box"
var img = document.getElementById('box'); 獲取到這個圖片並用變數記住
img.style.transform = "rotate(90deg)"; 改變這個圖片的css,旋轉90度

完畢!!!

閱讀全文

與js怎麼旋轉圖片相關的資料

熱點內容
美術花盆和花的圖片簡單 瀏覽:143
水果怎麼擺好看圖片 瀏覽:537
千與千尋人物圖片大全 瀏覽:242
委屈漫畫圖片女孩 瀏覽:403
背景圖片簡約可愛清新 瀏覽:927
圖片狼抱著一個女孩 瀏覽:170
文檔中圖片如何快捷設置大小 瀏覽:255
貂蟬去衣服圖片大全 瀏覽:91
美女背影高清壁紙圖片全屏 瀏覽:59
圖片如何設置標題 瀏覽:807
漂亮文字動態圖片大全 瀏覽:64
七天打卡表可愛圖片 瀏覽:35
波波頭發型效果圖片 瀏覽:659
圖片插入word中無法選中怎麼辦 瀏覽:220
大叔洗衣服的圖片 瀏覽:444
Word里圖片置頂如何加空格 瀏覽:201
蔣丞圖片高清動漫 瀏覽:303
放美女和平精英圖片 瀏覽:386
黑鼻子可愛圖片 瀏覽:854
word轉換pdf時圖片丟失 瀏覽:290