旋转菜单代码实现



如图所示,菜单的子模块沿着虚线顺时针旋转(虚线只是轨道示意用来理解的,实际的页面上没有虚线);

当鼠标进入菜单时,停止旋转,鼠标移除出,继续旋转;

请问这种旋转菜单的如何实现??
能有代码最好!谢谢了!

<!doctype html>
<html lang= "en" >
<head>
     <meta charset= "UTF-8"  />
     <meta http-equiv= "X-UA-Compatible"  content= "IE=edge,chrome=1"  />
     <title> 页面名称 </title>
<style type= "text/css" >
#box {
     position: relative;
     width: 500px;
     height: 500px;
     background:  #CCC;
}
#box div {
     position: absolute;
     border: 1px solid  #000;
     display: inline;
     background:  #FFF;
     padding: 10px;
}
</style>
</head>
<body>
<div id= "box" >
     <div>aaaaa</div>
     <div>bb</div>
     <div>ccccccc</div>
     <div>ddd</div>
     <div>eeeee</div>
</div>
<script type= "text/javascript" >
( function  () {
     var  box = document.getElementById( "box" );
     var  div = box.getElementsByTagName( "div" );
     var  cx = box.offsetWidth >> 1;
     var  cy = box.offsetHeight >> 1;
     var  len = div.length;
     var  radius = 200;
     var  loop = 0;
     function  draw() {
         loop += 0.02;
         for  ( var  i = 0; i < len; i++) {
             div[i].style.left = (Math.sin((Math.PI*2)*(i/len)+loop)*radius) + cx - (div[i].offsetWidth>>1) +  "px" ;
             div[i].style.top = (-Math.cos((Math.PI*2)*(i/len)+loop)*radius) + cy - (div[i].offsetHeight>>1) +  "px" ;
         }
     }
     var  timer = setInterval(draw, 50);
     for  ( var  i = 0; i < len; i++) {
         div[i].onmouseover =  function  () {
             clearInterval(timer);
         }
         div[i].onmouseout =  function  () {
             timer = setInterval(draw, 50);
         }
     }
})();
</script>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值