![JavaScript如何实现飘落星星特效的实例代码详解](https://100zi.50zi.cn/uploadfile/img/14/598/c4fe1e8522d1950b170e120d4854f492.jpg)
web前端|js教程
JavaScript,js,星星
web前端-js教程
这篇文章主要为大家详细介绍了基于JavaScript实现飘落星星特效,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
生活源码手机,ubuntu ui 自己做,怎么了配置tomcat,c 爬虫 淘宝,php和webpython区别,贵州seo优化搜索排名有什么用lzw
本文实例为大家分享了js飘落星星特效的具体代码,供大家参考,具体内容如下
选择源码,vscode设置字体底色,ubuntu邮箱搭建,tomcat缓存文件删除,日照 爬虫,php 字符串转十六进制,阜阳seo推广如何收费,discuz添加网站模板,微信公众号购买平台代码模板lzw
1.效果图
短信炸弹 网页版 源码,带不开vscode,eaidk ubuntu,tomcat和tongweb,sqlite如何执行语句,拖动选择插件,前端框架技术选择题,股票爬虫数据采集工具,php 判断是否是手机,潮州seo优化团队,五金店网站模板,模仿网页音乐播放器,微信端网页模板下载lzw
2.代码
Titleimg{ position: absolute; } body {background-image: url(img/bg.jpg); background-size: 100%; } function Star() {this.speed=10; this.img=new Image(); this.img.src="img/star"+parseInt(Math.random()*4+1)+".jpg"; 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)