📄 实例99.页面礼花效果.html
字号:
<BODY bgcolor=#000000>
<layer name="a0" left=10 top=10 visibility=show bgcolor="#ffffff" clip="0,0,1,1"></layer>
<layer name="a1" left=10 top=10 visibility=show bgcolor="#fff000" clip="0,0,1,1"></layer>
<layer name="a2" left=10 top=10 visibility=show bgcolor="#ffa000" clip="0,0,1,1"></layer>
<layer name="a3" left=10 top=10 visibility=show bgcolor="#ff00ff" clip="0,0,1,1"></layer>
<layer name="a4" left=10 top=10 visibility=show bgcolor="#00ff00" clip="0,0,1,1"></layer>
<layer name="a5" left=10 top=10 visibility=show bgcolor="#ff00ff" clip="0,0,1,1"></layer>
<layer name="a6" left=10 top=10 visibility=show bgcolor="#ff0000" clip="0,0,1,1"></layer>
<layer name="a7" left=10 top=10 visibility=show bgcolor="#ffffff" clip="0,0,1,1"></layer>
<layer name="a8" left=10 top=10 visibility=show bgcolor="#fff000" clip="0,0,1,1"></layer>
<layer name="a9" left=10 top=10 visibility=show bgcolor="#ffa000" clip="0,0,1,1"></layer>
<layer name="a10" left=10 top=10 visibility=show bgcolor="#ff00ff" clip="0,0,1,1"></layer>
<layer name="a11" left=10 top=10 visibility=show bgcolor="#00ff00" clip="0,0,2,2"></layer>
<layer name="a12" left=10 top=10 visibility=show bgcolor="#0000ff" clip="0,0,2,2"></layer>
<layer name="a13" left=10 top=10 visibility=show bgcolor="#ff0000" clip="0,0,2,2"></layer>
<div id="starsDiv" style="position:absolute;top:0px;left:0px">
<div style="position:relative;width:3px;height:3px;background:#ffffff;font-size:3px"></div>
<div style="position:relative;width:3px;height:3px;background:#fff000;font-size:3px"></div>
<div style="position:relative;width:3px;height:3px;background:#ffa000;font-size:3px"></div>
<div style="position:relative;width:3px;height:3px;background:#ff00ff;font-size:3px"></div>
<div style="position:relative;width:3px;height:3px;background:#00ff00;font-size:3px"></div>
<div style="position:relative;width:3px;height:3px;background:#0000ff;font-size:3px"></div>
<div style="position:relative;width:3px;height:3px;background:#FF0000;font-size:3px"></div>
<div style="position:relative;width:3px;height:3px;background:#ffffff;font-size:3px"></div>
<div style="position:relative;width:3px;height:3px;background:#fff000;font-size:3px"></div>
<div style="position:relative;width:3px;height:3px;background:#ffa000;font-size:3px"></div>
<div style="position:relative;width:3px;height:3px;background:#ff00ff;font-size:3px"></div>
<div style="position:relative;width:3px;height:3px;background:#ff00ff;font-size:3px"></div>
<div style="position:relative;width:3px;height:3px;background:#0000ff;font-size:3px"></div>
<div style="position:relative;width:3px;height:3px;background:#FF0000;font-size:3px"></div>
</div>
<SCRIPT LANGUAGE="JavaScript">
<!--
var Clrs = new Array(9); // 定义礼花颜色数组
Clrs[0] = 'ff0000';
Clrs[1] = '00ff00';
Clrs[2] = '000aff';
Clrs[3] = 'ff00ff';
Clrs[4] = 'ffa500';
Clrs[5] = 'ffff00';
Clrs[6] = '00ff00';
Clrs[7] = 'ffffff';
Clrs[8] = 'fffff0';
var sClrs = new Array(5); // 定义礼花颜色数组
sClrs[0] = 'ffa500';
sClrs[1] = '55ff66';
sClrs[2] = 'AC9DFC';
sClrs[3] = 'fff000';
sClrs[4] = 'fffff0';
var yBase;
var xBase;
var step;
var currStep = 0;
var Xpos = 1;
var Ypos = 1;
var initialStarColor = 'ffffff'; // 初始化礼花颜色
var Mtop = 0;
var Mleft = 0;
function fires() {
yBase = window.document.body.offsetHeight / 3; // 设定礼花出现范围高度界限
xBase = window.document.body.offsetWidth / 8; // 设定礼花出现范围宽度界限
step = 5; // 初始化礼花的速度
for ( i = 0 ; i < starsDiv.all.length ; i++ ) { // 循环礼花
for (ai = 0; ai < Clrs.length; ai++) { // 循环颜色
var c = Math.round(Math.random()*[ai]); // 随机分配颜色
}
if (currStep < 90)
starsDiv.all[i].style.background=initialStarColor;
if (currStep > 90)
starsDiv.all[i].style.background=Clrs[c]; // 礼花背景颜色
starsDiv.all[i].style.top = Mtop + yBase*Math.sin((currStep+i*5)/3)*Math.sin(550+currStep/100) // 礼花上边距位置
starsDiv.all[i].style.left = Mleft + yBase*Math.cos((currStep+i*5)/3)*Math.sin(550+currStep/100) // 礼花左边距位置
}
currStep+= step;
setTimeout("fires()",5); // 每5毫秒执行函数一次
if (currStep == 220) {
currStep = -10;
for (n = 0; n < sClrs.length; n++) {
var k = Math.round(Math.random()*n);
}
initialStarColor = sClrs[k];
Dtop = window.document.body.clientHeight - 250;
Dleft = xBase * 3.5;
Mtop = Math.round(Math.random()*Dtop); // 随机确定位置
Mleft = Math.round(Math.random()*Dleft);
document.all.starsDiv.style.top = Mtop+document.body.scrollTop;
document.all.starsDiv.style.left = Mleft+document.body.scrollLeft;
if ((Mtop < 20) || (Mleft < 20)) {
Mtop += 90;
Mleft += 90;
}
}
}
fires();
//-->
</script>
</body>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -