javascript下雨效果的代码,js实现星星特效代码

 操作系统     |      2020-02-02 20:55

<html>
<head>
<style>
.drop { position: absolute; width: 3;  filter: flipV(), flipH();
font-size: 40; color: blue }
</style>
<script language="javascript">
snow = false;    // false-雨;   true-雪
snowsym = " * "  //这是符号
rainsym = " ' "  //这儿可以放图片.
howmany = 10     //雨滴多少/雪片?
/**************不要给变下面的参数***********/
if(snow){sym = snowsym; speed=1; angle=10; drops=howmany}
else{sym = rainsym; speed=50; drops=howmany; angle=6}
movex = -speed/angle; movey = speed; count = 0;
function moverain(){
for(move = 0; move < drops; move++){
xx+=movex;  yy+=mv;
hmm = Math.round(Math.random()*1);
if(xx < 0){xx = maxx+10;}
if(yy > maxy){yy = 10;}
drop.left = xx
drop.top = yy+document.body.scrollTop;
}setTimeout('moverain()','1')}
</script>
</head>
<body bgcolor=#000000>
<script language="javascript">
if (document.all){
drop = new Array(); xx = new Array(); yy = new Array(); mv = new

js实现飞入星星特效代码,js实现星星特效代码

本文实例讲述了js实现飞入星星特效代码,分享给大家供大家参考。

具体实现代码如下:

复制代码 代码如下:

<html>
<head>
<title>星空极速飞入效果</title>
<style type="text/css">
<!--
body {
background-color: #000066;
}
-->
</style>
</head>
<body>
<script language="JavaScript">
xL=8;
xH=xW=xR=xE=xMY=xMX=xWd=xHd=0;
xF=new Array();
xY=new Array();
xX=new Array();
xS=new Array();
xA=new Array();
xB=new Array();
ini=new Array();
document.write('<div id="sdiv" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0; i < xL; i++){
 document.write('<div id="div" style="position:absolute;top:0;left:0;width:5px;height:5px;'+'font-size:10px;color:#ffffff">.</div>');
}
document.write('</div></div>');
function Set(){
 for (i=0; i < xL; i++){
  transfer(i)
  xF[i]=xW/14;
 }
}
function Assign(){
 sdiv.style.top=document.body.scrollTop;
 for (i=0; i < xL; i++){
  xF[i]-=xS[i]*25;
  if (xF[i]必赢体育官方网站, < 4) xF[i]=3;
  div[i].style.top =xY[i];
  div[i].style.left=xX[i];
  div[i].style.fontSize=xF[i];
 }
}
function fly(){
 xMY=window.document.body.clientHeight/2;
 xMX=window.document.body.clientWidth/2;
 xWd=Math.round(Math.random()*40+5);
 xHd=Math.round(Math.random()*30+5);
 for (i=0; i < xL; i++){
  xY[i]=xA[i]+=(xMY-xA[i])*(xS[i]);
  xX[i]=xB[i]+=(xMX-xB[i])*(xS[i]);
  if ((xX[i] > xMX-xWd) && (xX[i] < xMX+xWd) && (xY[i] > xMY-xHd) && (xY[i] < xMY+xHd)){
   transfer(i)
  }
  if ((xX[i]<0)||(xX[i]>xW)||(xY[i]<0)||(xY[i]>xH)){
    xF[i]=xW/14;
  }
 }
 Assign();
 setTimeout('fly()',1);
}
function transfer(i){
 xH=window.document.body.offsetHeight;
 xW=window.document.body.offsetWidth;
 xA[i]=Math.round(Math.random()*xH);
 xB[i]=Math.round(Math.random()*xW);
 xS[i]=Math.random()*0.05+0.05;
 xR=Math.round(Math.random()*3);
 xE=Math.round(Math.random()*50+50);
 if (xR == 3) xB[i]=-xE;
 if (xR == 2) xB[i]=xW+xE;
 if (xR == 1) xA[i]=-xE;
 if (xR == 0) xA[i]=xH;
}
Set();
fly();
</script>
</body>
</html></td>
   </tr>
 </table>

希望本文所述对大家的javascript程序设计有所帮助

Array()
ly = "document.all['"; st = "'].style"
for(make = 0; make < drops; make++){
document.write('<div id="drop'+make+'" class=drop>'+sym+'</div>');
drop[make] = eval(ly+'drop'+make+st);
maxx = document.body.clientWidth-40
maxy = document.body.clientHeight-40
xx[make] = Math.random()*maxx;
yy[make] = -100-Math.random()*maxy;
drop[make].left = xx[make]
drop[make].top = yy[make]
mv[make] = (Math.random()*5)+speed/4;
drop[make].fontSize = (Math.random()*10)+20;
if(snow){col = 'white'}else{col = 'blue'}
drop[make].color = col;
}
window.onload=moverain
}
</script>
</body>
</html>

这个js特效代码 的图片怎更改??

var sohuFlash2 = new sohuFlash("../images/flaplus01.swf", "27", 520, 205, "7");
看到这句话了吧,他这个效果是将图片的这些地址作为参数传到这个flash里面的。所以这个特效的可复用是很差的。用不了,找别的吧  

上一篇:有谁为我哭泣,吹醒了心里那沉睡的思念 下一篇:没有了