js实现雪花漂浮飞舞特效

1个月前 (04-12 14:17)阅读35回复0
大陆
大陆
  • 管理员
  • 发消息
  • 注册排名1
  • 经验值4669
  • 级别管理员
  • 主题933
  • 回复2
楼主

这是一款网页雪花漂浮飞舞效果,需要用到雪花特效的朋友可以来参考这个例子,可自定义漂浮速度。

<!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=gb2312" />
<meta name="keywords" content="武鸣人网站,武鸣信息网,武鸣本地网,武鸣信息资源平台,减肥,健身,励志,励志语录,js特效,网页特效,www.wuming.ren">
<meta name="description" content="欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。">
<title>js实现雪花漂浮飞舞特效_武鸣人</title>
</head>
<style>
* {margin:0; padding:0; vertical-align:top;}
.xue{position:absolute;color:#fff;}
</style>
<body>
<a href="https://www.wuming.ren">武鸣人</a>,各种信息资源免费发布,分享励志语录经典短句,减肥健身常识,各种js特效代码。网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)<hr>
<!--欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。-->
<script type="text/javascript" src="https://www.wuming.ren/ad/tc.js"></script>
<script type="text/javascript" src="https://www.wuming.ren/ad/a.js"></script>
<div id="b_wuming_ren" style="position:absolute;top:0px;right:0px;width:400px;border:1px #000 solid;background:#fff;z-index:9;height:30px;"></div>
<div id="box_wuming_ren" 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_wuming_ren = document.getElementById("box_wuming_ren");
 var i= 0,c,d,wind_time;
 var all = 0,other = 0,wind=0;
 box_wuming_ren.style.width =  '1000px';
 document.getElementById("wind_button").onclick = function(){
  clearTimeout(wind_time);wind = 0;
  //document.getElementById("wind_id").value.match(/\d/);
  wind = parseInt(document.getElementById("wind_id").value);
  wind_run(wind);
 }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
 function gogo(){
  var a = document.createElement("div");
  a.innerHTML = '.';
  a.id = "xue" + i;
  a.className = "xue";
  a.style.top = parseInt(box_wuming_ren.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_wuming_ren.style.width) * ss + 'px';
  box_wuming_ren.appendChild(a);
  godown(a.id,a.id,8*Math.random());
  i++;
  all++;
  var x = 100 * Math.random()* Math.random();
  setTimeout('gogo()',x);
 };//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
 function removeElement(_element){//移除标签的函数
         var _parentElement = _element.parentNode;
         if(_parentElement){
                _parentElement.removeChild(_element);
         };
 };//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
 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_wuming_ren.style.height)){e = setTimeout("godown(\""+a+"\",\""+e+"\","+speed+")",20)}
  else{
   clearTimeout(e);
   removeElement(a1);
   speed=null;
   other++;
   document.getElementById('b_wuming_ren').innerHTML = "区域内还有"+(all-other)+"个雪花点."//
  };
 };//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
 function wind_run(wind){
  var a = document.getElementById("box_wuming_ren").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;};
 };//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
 gogo();
</script>
</body>
</html>


0
0
收藏0
回帖

js实现雪花漂浮飞舞特效 期待您的回复!

取消
载入表情清单……
载入颜色清单……
插入网络图片

取消确定

图片上传中
编辑器信息
提示信息