我想,jquery及其插件jQueryRotate.js能够完全满足你的需要,不但可以90度,任意度都行.还带动画效果.=== 下面是演示代码. demo function demo_rotate(){ //$("#demo_r").rotate(90);('#demo_r').rotate({maxAngle:25,minAngle:-55,bind:[{"mouseover":function(){$(this).rotate...
JavaScript如何实现层或层里面内容的旋转?
<!-- 每点击一次,就旋转90度 -->
<div>
<img style='filter:progid:DXImageTransform.Microsoft.Matrix(SizingMethod="auto expand",FilterType="bilinear",Dx=0,Dy=0)' id=w src='d:\10.jpg' width="292" height="429"></div>
<button onclick='with(w.filters.item(0)){try{P==1}catch(e){P=0}P+=90;z=Math.PI*2/360*P;m12=-Math.sin(z);m21=Math.sin(z);m11=Math.cos(z);m22=Math.cos(z)}'>每点击一次,就旋转90度</button>2010-04-20
我想,jquery及其插件jQueryRotate.js能够完全满足你的需要,不但可以90度,任意度都行.还带动画效果.
=========
下面是演示代码.
<html>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" ></meta>
<head>
<title>
demo
</title>
<script src="jquery.js" type="text/javascript"></script>
<script src="jQueryRotate.js" type="text/javascript"></script>
<script>
function demo_rotate(){
//$("#demo_r").rotate(90);
$('#demo_r').rotate({maxAngle:25,minAngle:-55,
bind:
[
{"mouseover":function(){$(this).rotateAnimation(85);}},
{"mouseout":function(){$(this).rotateAnimation(-35);}}
]
});
}
</script>
</head>
<body>
<div id="showTime">
<table class='itable' width='100%' id='timetable' >
<tr>
<td class="test_c" id="one">
<img src="1.jpg" id="demo_r">
</td>
</tr>
<tr>
<td>
<input type="button" value="demo" onclick="demo_rotate();">
</td>
</tr>
</table>
</div>
</body>
</html>
你要找不到两个js文件,请联系我.给我留言.2010-04-19
先用 CSS 定义一个 class
.deg90 {
/* for firefox, safari, chrome, etc. */
-webkit-transform: rotate(-90deg);
-moz-transform: rotate(-90deg);
/* for ie */
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3);
}
点按钮的时候,给你的 div 加上这个 class,就行了。
给元素加 class 的函数:
function addClass(element, value) {
if (!element.className) {
element.className = value;
} else {
var newClassName = element.className;
newClassName += " ";
newClassName += value;
element.className = newClassName;
}
}
例:
如果 HTML 代码是
<div id="rotate90"> ... </div>
按钮 onclick 的 JS 代码
addClass(document.getElementById('rotate90'), 'deg90');2010-04-20
<!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['-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); } }</script></head><body><button onclick="start();">rotate</button><div id="div" style="border-radius: 90px; -webkit-transform: rotate(10deg);">ROTATE</div></body></html>2015-02-05