跟随和围绕鼠标旋转的七种色彩的小球js特效 来源:未知 作者: 大小: 大小: 0KB 点击次数: 发布时间:2017-10-09 16:24:15 去下载 去预览 特效介绍 跟随和围绕鼠标旋转的七种色彩的小球js特效。运行下面的代码查看效果。本特效只支持IE内核浏览器。 <html> <head> <title>跟随和围绕鼠标旋转的七种色彩的小球特效</title> <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> </head> <body bgColor="#000000"> <script language="JavaScript"> <!-- //To add more stars simply add more colours in below array!! colours=new Array('ff0000','00ff00','3366ff','ff00ff','ffa500','ffffff','fff000') //Alter nothing below!! amount=colours.length; YgetDelay=0,XgetDelay=0,Ydelay=0,Xdelay=0,ns=(document.layers)?1:0,step=0.2,currStep=0,my=0,mx=0; if (ns){ for (i=0; i < amount; i++) document.write('<LAYER NAME="nsstars'+i+'" BGCOLOR='+colours[i]+' CLIP="0,0,2,2"></LAYER>'); } else{ document.write('<div id="ie" style="position:absolute;top:0;left:0;"><div style="position:relative">'); for (i=0; i < amount; i++) document.write('<span id="iestars" style="position:absolute;top:0;left:0;width:2px;height:2px;background:'+colours[i]+';font-size:2px"></span>'); document.write('</div></div>'); } if (ns){ window.captureEvents(Event.MOUSEMOVE); function nMouse(evnt){ my=evnt.pageY;mx=evnt.pageX } window.onMouseMove=nMouse; } else{ function iMouse(){ my=event.y;mx=event.x; } document.onmousemove=iMouse } function stars(){ if (!ns)ie.style.top=document.body.scrollTop; for (i=0; i < amount; i++) { var layer=(document.layers)?document.layers["nsstars"+i]:iestars[i].style; layer.top= Ydelay+100*Math.sin((5*Math.sin((currStep-15.99)/10))+i*70)*Math.sin((currStep)/10)*Math.cos((currStep+i*25)/10); layer.left=Xdelay+180*Math.cos((5*Math.sin((currStep-15.99)/10))+i*70)*Math.sin((currStep)/10)*Math.cos((currStep+i*25)/10); } currStep+=step; } function delay(){ Ydelay = YgetDelay+=(my-YgetDelay)*1/20; Xdelay = XgetDelay+=(mx-XgetDelay)*1/20; stars(); setTimeout('delay()',10); } delay(); //--> </script> <script language="JavaScript"> <!-- hide function goHist(a) { history.go(a); } //--> </script> </body> </html> 提示:您可以先修改部分代码再运行 使用方法 暂无。 TAGS: js小球特效 js鼠标跟随 js色彩特效 下载 预览 上一篇: jquery文字颜色渐变,jquery背景色渐变,jquery color 下一篇: 纯CSS3打造来回滚动和碰撞的立体桌球