最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

JS實(shí)現(xiàn)跟隨鼠標(biāo)閃爍轉(zhuǎn)動(dòng)色塊的方法

 更新時(shí)間:2015年02月26日 15:07:40   作者:代碼家園  
這篇文章主要介紹了JS實(shí)現(xiàn)跟隨鼠標(biāo)閃爍轉(zhuǎn)動(dòng)色塊的方法,涉及javascript操作html元素及css樣式的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了JS實(shí)現(xiàn)跟隨鼠標(biāo)閃爍轉(zhuǎn)動(dòng)色塊的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

復(fù)制代碼 代碼如下:
<html>
<head>
<title>JS跟隨鼠標(biāo)閃爍轉(zhuǎn)動(dòng)的色塊</title>
</head>
<body>
<script language="JavaScript">
<!--
if (document.all){
colours=new Array('ff0000','00ff00','3366ff','ff00ff','ffa500','ffffff','fff000')
amount=colours.length;
YgetDelay=0,XgetDelay=0,Ydelay=0,Xdelay=0,step=0.2,currStep=0,my=0,mx=0;
document.write('<div id="ie" style="position:absolute;top:0;left:0;"><div style="position:relative">');
for (i=0; i < amount; i++)
document.write('<div id="iestars" style="position:absolute;top:0px;left:0px;height:50px;width:50px;font-family:Courier New;font-size:5px;color:'+colours[i]+';padding-top:20px;text-align:center">.</div>');
document.write('</div></div>');
ini=1;
gstep=1;
function iMouse(){
my=event.y;mx=event.x;
}
document.onmousemove=iMouse
function dim(){
ini-=gstep;
dt=setTimeout('dim()',10);
if (ini < 2){
clearTimeout(dt);
glow();
}
}
function glow(){
ini+=gstep;
gt=setTimeout('glow()',10);
if (ini > 14){
clearTimeout(gt);
dim();
}
}
function stars(){
ie.style.top=document.body.scrollTop;
for (i=0; i < amount; i++)
 {
 var layer=iestars[i].style;
 layer.filter='glow(color='+colours[i]+', strength='+ini+')';
 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();
glow();
}
//-->
</script>
</body>
</html>

希望本文所述對(duì)大家的javascript程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論

邛崃市| 枣庄市| 进贤县| 如东县| 丹寨县| 九龙坡区| 高尔夫| 绥德县| 大名县| 九寨沟县| 嵩明县| 东宁县| 东城区| 菏泽市| 漳平市| 保德县| 红原县| 浮山县| 浏阳市| 景泰县| 宜城市| 海原县| 偏关县| 定陶县| 神木县| 皋兰县| 南木林县| 仁寿县| 崇州市| 盐源县| 沙田区| 清水河县| 鲁甸县| 汨罗市| 甘洛县| 新安县| 罗江县| 嵊州市| 曲松县| 昭平县| 卢氏县|