国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

基于JavaScript實現飄落星星特效

2019-11-19 15:50:57
字體:
來源:轉載
供稿:網友

本文實例為大家分享了js飄落星星特效的具體代碼,供大家參考,具體內容如下

1.效果圖

2.代碼

<!DOCTYPE html> <html lang="en"> <head>  <meta charset="UTF-8">  <title>Title</title>  <style>   img{    position: absolute;   }   body {     background-image: url(img/bg.jpg);    background-size: 100%;    }  </style>   <script>    function Star() {      this.speed=10;    this.img=new Image();    this.img.src="img/star"+parseInt(Math.random()*4+1)+".png";    this.img.style.width=50+'px';    this.img.style.height=50+'px';    this.img.style.top=Math.random()*window.innerHeight+1+'px';    this.img.style.left=Math.random()*window.innerWidth+1+'px';    document.body.appendChild(this.img);   }    Star.prototype.slip=function () {     var that=this;    function move() {     that.img.style.top=that.img.offsetTop+that.speed+'px';     console.log(that.img.offsetTop+"star");     console.log(window.innerHeight+"window");     if(that.img.offsetTop>window.innerHeight){      clearInterval(sh);      that.img.style.height=0;      that.img.style.width=0;     }    }    var sh=setInterval(move,100);   }     setInterval(function () {     for(var i=1;i<5;i++){     new Star().slip();     }    },1000)   </script>  </head>  <body>   </body> </html> 

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 囊谦县| 额尔古纳市| 偃师市| 敖汉旗| 积石山| 永顺县| 台北县| 简阳市| 江城| 即墨市| 昆山市| 敦煌市| 博乐市| 苗栗县| 区。| 松潘县| 双城市| 神池县| 乌鲁木齐县| 洛川县| 炎陵县| 江源县| 监利县| 泰和县| 澎湖县| 塔河县| 华蓥市| 甘南县| 建始县| 旬邑县| 开原市| 新绛县| 定安县| 察隅县| 玉龙| 池州市| 根河市| 隆回县| 四川省| 湘乡市| 于都县|