JS雪花飘飘,下个不停的效果
来源:互联网 发布:ios手机登录淘宝网页版 编辑:程序博客网 时间:2024/04/27 20:16
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>雪花飘啊飘</title>
</head>
<style>
* {margin:0; padding:0; vertical-align:top;}
.xue{position:absolute;color:#fff;}
</style>
<body>
<div id="bbb" style="position:absolute;top:0px;right:0px;width:400px;border:1px #000 solid;background:#fff;z-index:9;height:30px;"></div>
<div id="box" style="height:600px;position:relative;border:1px red solid;background:#000;overflow:hidden;"></div>
<div style="position:absolute;top:0px;right:400px;border:1px #000 solid;background:#fff;width:400px;height:30px;z-index:5;">
<input id="wind_id" value="10" />级风
<input id="wind_button" type=button value="雪花飘啊飘飘啊飘" />
</div>
<script>
var box = document.getElementById("box");
var i= 0,c,d,wind_time;
var all = 0,other = 0,wind=0;
box.style.width = '1000px';
document.getElementById("wind_button").onclick = function(){
clearTimeout(wind_time);wind = 0;
wind = parseInt(document.getElementById("wind_id").value);
wind_run(wind);
}
function gogo(){
var a = document.createElement("div");
a.innerHTML = '.';
a.id = "xue" + i;
a.className = "xue";
a.style.top = parseInt(box.style.height) * (Math.random() > 0.3 ? Math.random() : 0) + 'px';
if(wind != 0){var ss = Math.random() > Math.abs(wind*0.025) ? Math.random() : (wind > 0 ? 0 : 1) ;}else{var ss = Math.random()}
a.style.left = parseInt(box.style.width) * ss + 'px';
box.appendChild(a);
godown(a.id,a.id,8*Math.random());
i++;
all++;
var x = 100 * Math.random()* Math.random();
setTimeout('gogo()',x);
};
function removeElement(_element){//移除标签的函数
var _parentElement = _element.parentNode;
if(_parentElement){
_parentElement.removeChild(_element);
};
};
function godown(a,e,speed){
if(speed < 3){speed = 3}
var a1 =document.getElementById(a);
a1.style.top = parseInt(a1.style.top) + speed +'px';
if(parseInt(a1.style.top) < parseInt(box.style.height)){e = setTimeout("godown(\""+a+"\",\""+e+"\","+speed+")",20)}
else{
clearTimeout(e);
removeElement(a1);
speed=null;
other++;
document.getElementById('bbb').innerHTML = "区域内还有"+(all-other)+"个雪花点."//
};
};
function wind_run(wind){
var a = document.getElementById("box").getElementsByTagName('div');
for(var i = 0;i<a.length;i++){
a[i].style.left = parseInt(a[i].style.left) + wind +'px';
};
if(Math.abs(wind) > 0.1){wind_time = setTimeout("wind_run("+wind+")",20)}
else{clearTimeout(wind_time);wind = 0;};
};
gogo();
</script>
<div><A href="http://www.999jiujiu.com/">http://www.999jiujiu.com/</A></div>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>雪花飘啊飘</title>
</head>
<style>
* {margin:0; padding:0; vertical-align:top;}
.xue{position:absolute;color:#fff;}
</style>
<body>
<div id="bbb" style="position:absolute;top:0px;right:0px;width:400px;border:1px #000 solid;background:#fff;z-index:9;height:30px;"></div>
<div id="box" style="height:600px;position:relative;border:1px red solid;background:#000;overflow:hidden;"></div>
<div style="position:absolute;top:0px;right:400px;border:1px #000 solid;background:#fff;width:400px;height:30px;z-index:5;">
<input id="wind_id" value="10" />级风
<input id="wind_button" type=button value="雪花飘啊飘飘啊飘" />
</div>
<script>
var box = document.getElementById("box");
var i= 0,c,d,wind_time;
var all = 0,other = 0,wind=0;
box.style.width = '1000px';
document.getElementById("wind_button").onclick = function(){
clearTimeout(wind_time);wind = 0;
wind = parseInt(document.getElementById("wind_id").value);
wind_run(wind);
}
function gogo(){
var a = document.createElement("div");
a.innerHTML = '.';
a.id = "xue" + i;
a.className = "xue";
a.style.top = parseInt(box.style.height) * (Math.random() > 0.3 ? Math.random() : 0) + 'px';
if(wind != 0){var ss = Math.random() > Math.abs(wind*0.025) ? Math.random() : (wind > 0 ? 0 : 1) ;}else{var ss = Math.random()}
a.style.left = parseInt(box.style.width) * ss + 'px';
box.appendChild(a);
godown(a.id,a.id,8*Math.random());
i++;
all++;
var x = 100 * Math.random()* Math.random();
setTimeout('gogo()',x);
};
function removeElement(_element){//移除标签的函数
var _parentElement = _element.parentNode;
if(_parentElement){
_parentElement.removeChild(_element);
};
};
function godown(a,e,speed){
if(speed < 3){speed = 3}
var a1 =document.getElementById(a);
a1.style.top = parseInt(a1.style.top) + speed +'px';
if(parseInt(a1.style.top) < parseInt(box.style.height)){e = setTimeout("godown(\""+a+"\",\""+e+"\","+speed+")",20)}
else{
clearTimeout(e);
removeElement(a1);
speed=null;
other++;
document.getElementById('bbb').innerHTML = "区域内还有"+(all-other)+"个雪花点."//
};
};
function wind_run(wind){
var a = document.getElementById("box").getElementsByTagName('div');
for(var i = 0;i<a.length;i++){
a[i].style.left = parseInt(a[i].style.left) + wind +'px';
};
if(Math.abs(wind) > 0.1){wind_time = setTimeout("wind_run("+wind+")",20)}
else{clearTimeout(wind_time);wind = 0;};
};
gogo();
</script>
<div><A href="http://www.999jiujiu.com/">http://www.999jiujiu.com/</A></div>
</body>
</html>
0 0
- JS雪花飘飘,下个不停的效果
- 雪花飘飘效果
- java 实现的飘雪花效果
- 天上飘雪花js
- JS实现飘落的雪花效果
- ios中实现3D效果--雪花飘的效果
- dx粒子效果雪花飘
- 简单实现飘雪花效果
- 雪花飘飘动画效果
- 漫天的雪花飘~~
- 制作网页雪花飘飘效果
- 雪花飘
- 雪花飘飘的时节
- 网页的雪花飘落效果
- 雪花飘落的动态效果
- 聊天过程中的飘雪花 ,雪花堆积,雪花消融,聊天过程中飘出的图片,动画
- 《IOS疯狂讲义》雪花飘飘效果实现
- 用CAEmitterLayer实现粒子动画飘雪花效果
- 《游戏引擎架构》中英词汇索引表
- PHP:40+开发工具推荐
- 自定义标签去除html
- CSDN 的MarkDown
- ubuntu更新系统后无法进入系统,黑屏的原因
- JS雪花飘飘,下个不停的效果
- python13:类
- 黑马程序员—OC语言基础—面向对象的三大特性(2)
- May~~~
- POJ 2528 Mayor's posters
- 神经网络C++代码
- VirtualBox安装增强功能包实现资源共享
- iOS 版百度地图 SDK 满视口显示一组大头针
- iphone开发 地图线路