html的div旋转方向怎么写,html中 Div旋转90度怎么写代码? 麻烦会的给写一下,最好加上注释以方便我理解...

本文介绍了如何使用HTML和CSS实现Div元素的旋转,包括HTML5和IE浏览器的兼容性处理。提供了详细的代码示例,并通过注释帮助理解旋转原理和设置方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

HTML>

YuGiOh

#div {

position: absolute;

top: 50px;

left: 300px;

width: 300px;

height: 300px;

line-height: 300px;

text-align: center;

border: 1px solid black;

}

var rotateHTML5 = function (limit)

{

var reg = /(rotate\([\-\+]?((\d+)(deg))\))/i;

var wt = 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);

}

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);

}

}

rotate

ROTATE
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值