css+js实现div旋转
看到百度音乐播放器的播放专辑类似于vcd播放光碟一样按照一个方向旋转。于是乎想也来实现一个。直接贴代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<style type="text/css">
.rotatedemo
{
width:100px;
height:100px;
background-color:yellow;
}
</style>
<script src="jquery-1.8.3.min.js"></script>
<script type="text/javascript">
var i=1;
function round(){
$(".rotatedemo").css("-webkit-transform","rotate("+i+"deg");
if(i==360) i=1
else i=i+1;
}
function rotate()
{
self.setInterval("round()",50);
}
</script>
<body>
<div class="rotatedemo">
<p>hello</p>
</div>
<div>
<input type="button" name="rotate" value="rotate" onclick="rotate()"/>
</div>
</body>
</html>
主要控制-webkit-transform这个属性就能控制div的旋转。
浙公网安备 33010602011771号