首页 >

javascript实现随机显示星星特效【javascript】

web前端|js教程javascript实现随机显示星星特效【javascript】
javascript随机显示星星,javascript显示星星,javascript显示星星特效
web前端-js教程
本文实例讲解了javascript实现随机显示星星特效的详细代码,具体内容如下
微信第订票系统源码,vscode不折叠注释,ubuntu大量驱动,tomcat部署不了,sqlite 字符串转,前端框架ie8支持,爬虫高手简历怎么写,php网站流量,文昌谷歌seo公司,nitc企业智能营销网站,爱国网页源码,登录 注册 模板lzw
(1)网页背景是黑的
(2)星星随机大小:min=15,max=80
(3)星星的坐标是随机的:
x_left=0,x_right=(浏览器宽-星星宽)
y_top=0,y_bottom=?
(4)单击某个星星,星星消失

(5)网页加载完成,开始显示星星

(6)定时器:每隔一个周期,插入一个星星
php实验室管理源码,vscode分屏看HTML,ubuntu系统优盘,tomcat怎么打开url,爬虫轩,php投票模板,扬州做seo优化推广,小说网站java模板下载,九宫格菜单网页模板lzw
无标题文档//定义全局变量var img_width_min = 15;var img_width_max = 80;var x_left = 0;var x_right = 0;var y_top = 0;var y_bottom = 0;//定义初始化的函数function init(){ document.body.bgColor = "#000"; x_right = window.innerWidth - img_width_max; y_bottom = window.innerHeight - img_width_max; //定时器 setInterval("showStar()",1000);}//显示星星function showStar(){ //创建一个图片 var node_img = document.createElement("img"); //随机图片大小和随机坐标 var width = getRandom(img_width_min,img_width_max); var x = getRandom(x_left,x_right); var y = getRandom(y_top,y_bottom); //增加src的属性 node_img.setAttribute("src","images/xingxing.jpg"); //增加style属性 var style = "position:absolute;left:"+x+"px;top:"+y+"px;"; style += "width:"+width+"px;"; node_img.setAttribute("style",style); //增加一个onclick事件属性 node_img.setAttribute("onclick","removeImg(this)"); //将图片追加到元素下 document.body.appendChild(node_img);}function removeImg(obj){ document.body.removeChild(obj);}function getRandom(min,max){ return Math.floor(Math.random()*(max-min)+min);}
滑动触发列表项菜单源码,ubuntu下scp文件,打开tomcat8秒退,爬虫抓取显示,html速度快还是php,国双seo方案lzw

  • 暂无相关文章