我的元素确实围绕一个点旋转。 JSFiddle
HTML
<div class="center-dot">
<div class="dot"></div>
<div class="one"></div>
<div class="two"></div>
</div>
CSS:
.center-dot {position:relative;top:200px;left:200px;}
.dot {width:3px;height:3px;background:blue;}
.one {width:40px;height:40px;border-radius:40px;background:red;position:absolute;}
.two {width:40px;height:40px;border-radius:40px;background:green;position:absolute;}
JS:
var one = $('.one'),
two = $('.two');
var one_start = 0,
two_start = 0;
setInterval(function(){
++one_start;
var one_css = {
'left': Math.sin(one_start * 0.0010) * 100 ,
'top': Math.cos(one_start * 0.0010) * 100
}
one.css(one_css);
++two_start;
var two_css = {
'left': Math.sin(two_start * 0.0025) * 200 ,
'top': Math.cos(two_start * 0.0025) * 200
}
two.css(two_css);
}, 1);
但他并不完全这样做,而是喜欢它曲折。
如何确保元素做了干净的圆圈?