2011-01-24 80 views

回答

5

最简单我能想到的是:

  1. 使相对
  2. 使动画元素是上面
  3. 计算顶子,使用留下的中心点位置:
    math.sin(时间*(角/秒))*距离
    math.cos(....)

简单的演示:

var elem = $('h1:eq(0)') 
    .append('<span id="round" style="position:absolute;background-color:red;">&nbsp;</span>') 
    .css('position','relative') 
    .find('span#round'); 

var i = 0; 
setInterval(function(){  
    ++i; 
    elem.css({'left': Math.sin(i * 0.02) * 100, 'top': Math.cos(i * 0.02) * 100});}, 100); 


看到它在行动jsfiddle