没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
js实现宇宙星空背景效果的方法实现宇宙星空背景效果的方法
主要介绍了js实现宇宙星空背景效果的方法,实例分析了javascript中动画效果的实现技巧,具有一定参考借鉴价值,
需要的朋友可以参考下
本文实例讲述了js实现宇宙星空背景效果的方法。分享给大家供大家参考。具体实现方法如下:
复制代码 代码如下:
<!DOCTYPE html PUBLIC "-//W3C//h2D XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/h2D/xhtml1-
transitional.h2d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<TITLE>宇宙星空背景效果,Js特效</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
.star {
position:absolute;
layer-background-color:white;
visibility:visible;
top:-50px;
width:50px;
height:50px;
font-size:1px;
background-color:white;
}
.60pt{font-size:60pt;color:#ff66cc;}
</style>
<SCRIPT LANGUAGE="JavaScript">
<!--
var starnum = 75; // 星星的数目
var isNS = (document.layers);
var _all = (isNS)? '' : 'all.';
var _style = (isNS) ? '' : '.style';
var xoffset, yoffset, w_x, w_y, tmpx, tmpy, scrlx, scrly;
function getstartpos(obj) { //定义星星移动的起始位置
obj.deltay = Math.floor(Math.random() * 12); //用随机函数决定
obj.deltax = Math.floor(Math.random() * 12);
obj.xdir = (Math.floor(Math.random() * 2) == 1) ? '+' : '-';
obj.ydir = (Math.floor(Math.random() * 2) == 1) ? '+' : '-';
obj.counter = 1;
if (isNS) {
obj.clip.width = 1;
obj.clip.height = 1;
obj.moveTo(xoffset+pageXOffset, yoffset+pageYOffset);
} else {
obj.width = 1;
obj.height = 1;
obj.pixelTop = yoffset+document.body.scrollTop;
obj.pixelLeft = xoffset+document.body.scrollLeft;
}
}
function movestar(starN) //移动星星的位置
{
tmpx = starN.deltax*starN.counter+starN.counter;
tmpy = starN.deltay*starN.counter+starN.counter;
if (isNS) {
starN.clip.width = starN.counter / 3;
starN.clip.height = starN.counter / 3;
scrlx = pageXOffset;
scrly = pageYOffset;
if ((starN.left+tmpx >= w_x+scrlx) || (starN.top+tmpy >= w_y+scrly) || (starN.left-tmpx <= scrlx) || (starN.top-tmpy <= scrly)) {
getstartpos(starN);
} else {
eval('starN.moveBy('+starN.xdir+tmpx+', '+starN.ydir+tmpy+')');
}
} else {
资源评论
weixin_38738005
- 粉丝: 5
- 资源: 895
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功