js中如何计算子元素在一个圆中的位置

这就是用到了公式,当初上学学习不认真,现在恶补一下吧,

              var $moona = $('div.moon div.box nav a');
			for(var i= 0,l=$moona.length; i<$moona.length; i++){
				$moona[i].style.left=(50 - 35*Math.cos(-0.5 * Math.PI - 2*(1/l)*i*Math.PI)).toFixed(4)+"%";
				$moona[i].style.top=(50 + 35*Math.sin(-0.5 * Math.PI - 2*(1/l)*i*Math.PI)).toFixed(4)+"%";
			}

  

cos值 和sin值  好好再复习一下吧

下面就是最后的效果了:

posted on 2016-03-08 23:47  金甲  阅读(481)  评论(0)    收藏  举报

导航