transform复合属性(transform 属性如何让一个div不停的旋转)

本文目录
transform 属性如何让一个div不停的旋转
《!DOCTYPE HTML》
《html》
《head》
《meta charset=UTF-8》
《title》YuGiOh《/title》
《style type="text/css"》
#div {
position: absolute;
top: 50px;
left: 300px;
width: 300px;
height: 300px;
line-height: 300px;
text-align: center;
border: 1px solid black;
}
《/style》
《script type="text/javascript" src="jquery-1.8.0.min.js"》《/script》
《script type="text/javascript"》
var rotateHTML5 = function (limit)
{
var reg = /(rotate\(?((\d+)(deg))\))/i;
var wt = div.style, wts = wt.match (reg);
var $2 = RegExp.$2;
console.log ($2);
div.style = wt.replace ($2, parseFloat (RegExp.$3) + limit + RegExp.$4);
}
var rotateIE = function (obj)
{
var d = !!obj.d ? obj.d : 1;
var r = d * Math.PI / 180;
costheta = Math.cos (r);
sintheta = Math.sin (r);
obj.style.filter = "progid:DXImageTransform.Microsoft.Matrix()";
var item = obj.filters.item (0);
var width = obj.clientWidth;
var height = 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 ()
{
var dx = d + 1;
dx = dx 》 360 ? 1 : dx;
obj.d = dx;
rotate (obj, dx);
}, 30);
};
var start = function ()
{
if (!!div.interval)
{
clearInterval (div.interval);
delete div.interval;
}
else
{
div.interval = setInterval (function ()
{
/.*webkit.*/i.test (navigator.userAgent) ? rotateHTML5 (1) : rotateIE (div);
}, 30);
}
}
《/script》
《/head》
《body》
《button onclick="start();"》rotate《/button》
《div id="div" style="border-radius: 90px; -webkit-transform: rotate(10deg);"》ROTATE《/div》
《/body》
《/html》
IE11中如何实现transform的rotate属性
filter: progid:DXImageTransform.Microsoft.Matrix(sizingMethod=’auto expand’, M11=0.866025404, M12=0.5, M21=-0.5, M22=0.866025404) ;
笔记:Matrix 滤镜在旋转方面需要用到 M11 M12 M21 M22 四个参数,分别代表 cos(旋转的角度)、-sin(旋转的角度)、sin(旋转的角度)、cos(旋转的角度)。

更多文章:
blast premier春季赛(csgo战队vitality有谁)
2026年9月7日 21:50
全球新冠肺炎疫情背景下航运发展(盐田港复苏日志:半年历劫从“低谷”到“爆仓” 疫情之后巨轮如何越洋航行)
2026年9月7日 17:10
matlab求解带字母参数方程组(我想matlab求一个关于x,y的方程组 ab c d f e h m n 都是参数)
2026年9月7日 16:30
oracle中的循环语句(下面哪个不是oracle程序设计中的循环语句 a for)
2026年9月7日 15:30
电脑里2个系统怎么删除一个(电脑开机显示有两个系统,如何删除一个)
2026年9月7日 12:20





