導航:首頁 > 動漫圖片 > 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怎麼旋轉圖片相關的資料

熱點內容
圖庫圖片大全可愛蠟筆小新 瀏覽:643
秋天的衣服圖片簡筆畫 瀏覽:673
洛麗塔花嫁衣服圖片 瀏覽:75
怎麼做ps圖片視頻教程 瀏覽:991
手機怎麼百度到圖片 瀏覽:769
蘋果13如何提取圖片文字 瀏覽:235
可愛動漫害羞表情圖片 瀏覽:791
陌陌怎麼修改動態圖片 瀏覽:309
甜美發型圖片編發圖片 瀏覽:486
男生造型圖片2017 瀏覽:166
好看的原耽女孩圖片 瀏覽:776
可愛長嘴的圖片 瀏覽:25
美女騎戰車圖片 瀏覽:259
word圖片被表格遮擋無法選中 瀏覽:307
飄色發型圖片 瀏覽:925
昂克賽拉價格及圖片 瀏覽:737
真誠信任圖片大全 瀏覽:804
怎麼畫手圖片 瀏覽:215
圖片上面的字如何設置 瀏覽:714
word文檔怎麼把圖片全覆蓋 瀏覽:912