雪花下落+雪花颜色随机+形状随机
来源:互联网 发布:什么牌子虹吸壶 知乎 编辑:程序博客网 时间:2024/04/28 19:52
/*
想做一个有input用户输入参数的功能,目前还没能成功,有几个小问题,这个只能在js里自己改动
*/
/*js部分*/
!function()
{
window.fn={};
fn.snow=function(options){
var documentWidth=document.documentElement.clientWidth;
var documentHeight=document.documentElement.clientHeight;
var defaults={
sizeMax:25,
sizeMin:10,
newOn:150,
speed:10 //px
}
var option=options||defaults ;
var timer=setInterval(function()
{
var flakeDiv=document.createElement("div");
document.body.appendChild(flakeDiv);
var flakeOpacity=Math.random()+0.3;
var left=parseInt(Math.random()*documentWidth);
var size=(Math.random()*(option.sizeMax-option.sizeMin))+option.sizeMin;
var flakeBgcolor=function()
{
var bgcolor=new Array("LightPink","Pink","HotPink","DeepPink","Orchid","Plum","LightSkyBlue","DeepSkyBlue","CornflowBlue","Cyan","Teal","SpringGreen","Gold","GreenYellow","Wheat","#1AFD9C","#FFAF90");
//alert(bgcolor);
return bgcolor[parseInt(Math.random()*bgcolor.length)];
}
var borderRadius=Math.random()*50+'%'+' '+Math.random()*50+'%'+' '+Math.random()*50+'%'+' '+Math.random()*50+'%';
flakeDiv.style.cssText="border-radius:"+borderRadius+";position:absolute;width:"+size+"px;height:"+size+"px;background:"+flakeBgcolor()+";opacity:"+flakeOpacity+";left:"+left+"px;";
dropSnowanimate(flakeDiv);
},option.newOn);
function dropSnowanimate(obj){
var top=0;
var dropSnow=setInterval(function()
{
top+=option.speed; //top=0+10
obj.style.marginTop=top+'px';
if(top>=parseInt(documentHeight))
{
clearInterval(dropSnow);
flakeA.removeChild(obj);
}
},23);
}
}
}()
/*html部分*/
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<style>
*{
margin:0;
padding:0;
background:black;
}
</style>
</head>
<body></body>
<script type="text/javascript" src="mysnow.js" ></script>
<script>
fn.snow();
</script>
</html>
- 雪花下落+雪花颜色随机+形状随机
- Android雪花下落效果
- h5+js生成随机大小的雪花
- 雪花
- 雪花
- 雪花
- 雪花
- 雪花
- 雪花
- 雪花
- Android 给指定RelativeLayout添加雪花下落效果
- ios之下载进度条和雪花下落的功能实现
- 随机颜色
- 随机颜色
- 随机颜色
- 颜色随机
- 血色雪花
- js雪花
- SourceTree使用方法
- 索引范围扫描
- 一些关于path环境变量的问题
- LeetCode 141 Linked List Cycle和142 Linked List Cycle II
- JAVA中封装性的概念
- 雪花下落+雪花颜色随机+形状随机
- diff和patch使用总结
- 排序算法
- TableLayout(表格布局)
- PAT-A 1050. String Subtraction (20)
- PHP:访问控制
- 跟小博老师一起学JSP ——通信作用域
- libevent源码详解(四)应用流程详解
- Intellij idea 修改 tomcat发布项目的位置