js  怎么让文字做 圆周运动  

解决方案 »

  1.   

    先定义一个轨迹,然后每一个字都作为一个div,在这个轨迹上走,并旋转
      

  2.   


     var step = 1;
                        var r = 50;
                        window.setInterval(function () {
                            if (step == 360) {
                                step = 1;
                            }
                            document.getElementById("tt").style.left = 300 + r * Math.sin(step);
                            document.getElementById("tt").style.top = 200 + r * Math.cos(step);                        step += 0.05;
                        }, 1);
      

  3.   

     <div id='testDiv' style="top:70px;left:500px;position:absolute;width:400px;height:50px"></div><script language='javascript' type="text/javascript">
     Phrase="2010五月的鲜花全国大学生文艺演出舞美设计";
    Balises="";
    Taille=12; // 40 
    Midx=200;
    Decal=0.28;
    Nb=Phrase.length;
    y=-10000;
    Alpha=5;
    I_Alpha=0.05;
     var isIE=false;
    function init(){
     
    if(Phrase=="")
    {
        return;}
        for (x=0;x<Nb;x++){
          Balises=Balises + '<DIV Id=L' + x + ' STYLE="width:25px;height:25px;font-family:黑体;position:absolute;font-weight:bold;top:30px;left:' +(100+x*15) + 'px;z-index:0">'
           + Phrase.charAt(x) + '</DIV>'
        }
        document.getElementById('testDiv').innerHTML = Balises;
         if(navigator.userAgent.indexOf("MSIE")>0) { 
             isIE=true; 
         }
         TimeFontView=window.setTimeout("Alors()",150);
    }function Alors(){
    Alpha=Alpha-I_Alpha;
    for (x=0;x<Nb;x++){
    Alpha1=Alpha+Decal*x;
    Cosine=Math.cos(Alpha1);
    Ob=document.getElementById("L"+x);
    Ob.style.left=(Midx+100*Math.sin(Alpha1)) +"px";
    Ob.style.zIndex=20*Cosine + 50;
    Ob.style.fontSize=(Taille+5*Cosine +8) +"px";    //Ob.style.fontSize=Taille+25*Cosine;
    //Ob.style.color="rgb("+ (Cosine*80 +77) + ","+ (Cosine*80+177) + ",50)";
    if(isIE)
        Ob.style.color="rgb(255,"+ (Cosine*150 + 105) + ","+(Cosine*60)+")";
    else
        Ob.style.color = convert(255, (Cosine*150 + 105) ,(Cosine*60));
    }

    TimeFontView=window.setTimeout("Alors()",150);
    }
    function getRgb(rgb){
         var rgbArr = [];
         var newRgb = "";
      var r,g,b;
         var color = "";
         if(rgb.indexOf("rgb")!=-1){
          newRgb = rgb.substring(4,rgb.length-1);
          rgbArr = newRgb.split(",");
          if(rgbArr.length>2){
           r = rgbArr[0];
           g = rgbArr[1];
           b = rgbArr[2];
          }
         }
         return convert(r,g,b);
        }
     function   toHex(N){
      N=Math.max(0,N)
      N=Math.min(255,N)
      return "0123456789ABCDEF".charAt((N-N%16)/16) + "0123456789ABCDEF".charAt(N%16)
     }
    function convert(R,G,B) {
         R=Math.max(0,R)
      R=Math.min(255,R)
      G=Math.max(0,G)
      G=Math.min(255,G)
      B=Math.max(0,B)
      B=Math.min(255,B)
      var color="#"+this.toHex(R)+this.toHex(G)+this.toHex(B);
      return color;
       }
    init();</script>
      

  4.   


    hch126163
    (老胡)
    我是说 像钟表那样 的运动轨迹 而不是 那种向里滚动