在html中 鼠标点击图片后让图片一直不停的绕着自己的中心旋转 还有 播放区向左移动后 回不来了!!! html5 canvas写一个图片围绕图片中心一直旋转的代码...
HTML\u600e\u6837\u8ba9\u4e00\u4e2a\u56fe\u7247\u4ee5\u81ea\u8eab\u4e2d\u5fc3\u65cb\u8f6cCSS2.0\u5b9e\u73b0\u4e0d\u4e86\uff0cCSS3.0\u6709\u4e2arotate\u5c5e\u6027\uff0c\u5199\u6cd5\uff1axxx:hover{-webkit-transform:rotate(360deg)}\uff0c\u4f46\u662f\u4e0d\u517c\u5bb9IE10\u4ee5\u4e0b\u7684\u6d4f\u89c8\u5668
\u8fd8\u6709\u4e00\u79cd\u529e\u6cd5\uff0c\u518d\u505a\u4e00\u5f20\u65cb\u8f6c\u7684\u56fe\u7247\uff0c\u9f20\u6807hover\u7684\u65f6\u5019\u53d8\u6210\u90a3\u5f20\u65cb\u8f6c\u7684\u56fe\u7247\u5c31\u597d\u4e86\uff01
JS\u53ef\u80fd\u4e5f\u53ef\u4ee5\u5b9e\u73b0\uff0c\u4e0d\u8fc7\u5e94\u8be5\u4f1a\u5f88\u9ebb\u70e6
\u4e00\u5b9a\u8981\u7528canvas\u5417\uff1f\u8fd9\u91cc\u7ed9\u4f60\u4e00\u4e2a\u4ee3\u7801\uff0c\u770b\u770b\u80fd\u4e0d\u80fd\u53c2\u8003\u4e00\u4e0b\uff0c\u6709\u5fc5\u8981\u4f60\u6a21\u4eff\u7740\u6539\u6210canvas\u54af\u3002
\u4e0a\u4ee3\u7801(\u56fe\u7247\u81ea\u5df1\u627e\u4e00\u5f20)\uff1a
#rotate_img {
margin: 100px;
}
\u5f00\u59cb\u65cb\u8f6c
\u6682\u505c\u65cb\u8f6c
<!--
var x, n=0, rotINT;
function rotate() {
x = document.getElementById("rotate_img");
clearInterval(rotINT);
rotINT = setInterval("startRotate()",10);
}
function pause () {
clearInterval(rotINT);
}
function startRotate() {
n = n + 1;
x.style.transform = "rotate(" + n + "deg)";
x.style.webkitTransform = "rotate(" + n + "deg)";
x.style.OTransform = "rotate(" + n + "deg)";
x.style.MozTransform = "rotate(" + n + "deg)";
if (n == 180 || n == 360) {
if (n >= 360){
n = 0;
}
}
}
//-->
<!DOCTYPE HTML>
<html>
<head>
<meta charset=UTF-8>
<title>YuGiOh</title>
<style type="text/css">
*{
margin:0;
padding:0;
}
#div {
position: absolute;
top: 50px;
left: 300px;
width: 300px;
height: 300px;
line-height: 300px;
text-align: center;
border: 1px solid black;
border-radius: 160px;;
}
</style>
<script type="text/javascript">
var deg = 0;
var rotateHTML5 = function(limit) {
deg += limit;
deg = deg > 360 ? 1 : deg;
div.style['transform'] = div.style['-webkit-transform'] = 'rotate(' + deg + 'deg)';
}
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;
rotateIE(obj);
}, 30);
};
var start = function() {
if (!/.*MSIE.*/i.test(navigator.userAgent)) {
if ( !! div.interval) {
clearInterval(div.interval);
div.interval = null;
} else {
div.interval = setInterval(function() {
rotateHTML5(1);
}, 30);
}
} else {
if ( !! div.timer) {
clearTimeout(div.timer);
div.timer = null;
} else {
rotateIE(div);
}
}
}
</script>
</head>
<body>
<button onclick="start();">rotate</button>
<div id="div">ROTATE</div>
</body>
</html>
//--------------------------
var but = $(".but");
but.find(".close").click(function() {
but.stop().animate({
left: -parseFloat(but.css("left")) + "px"
}, 500);
});
扩展阅读:html点击按钮出现图片 ... html鼠标点击后改变 ... html点击图片放大效果 ... html鼠标悬浮图片变大 ... html鼠标点击图片放大 ... html鼠标移入显示图片 ... html鼠标点击改变颜色 ... 鼠标点击事件html代码 ... html图片点击后变另一张 ...