使用了particles.js
particles.js可以从github网站下载到最新的源码,网址是 https://github.com/VincentGarreau/particles.js/
使用方法非常简单
第一步,在html中引入脚本文件 particles.min.js,这个文件在下载的压缩包里可以找到
<script src="particles.min.js"></script>第二步,在html中放入一个div容器,设置id为particles-js。这个一般放在所有网页元素的最后面就可以。
<div id="particles-js"></div><style type="text/css">
#particles-js {
position: absolute
top:0
width:100%
}
</style>
第三步,设置窗口样式
<style type="text/css">#particles-js {
z-index: -1
position: absolute
top: 0
width: 100%
background: #aaa
}</style>
第四步,脚本生成粒子效果,可以单独放在一个js文件里,也可以放在<script>标签里。无论如何,这段脚本要出现在div容器之后。
particlesJS("particles-js", { "particles": { "number": { "value": 380, "density": { "enable": true, "value_area": 800}
}, "color": { "value": "#ffffff"
}, "shape": { "type": "circle", "stroke": { "width": 0, "color": "#000000"
}, "polygon": { "nb_sides": 5
}, "image": { "src": "img/github.svg", "width": 100, "height": 100
}
}, "opacity": { "value": 0.5, "random": false, "anim": { "enable": false, "speed": 1, "opacity_min": 0.1, "sync": false
}
}, "size": { "value": 3, "random": true, "anim": { "enable": false, "speed": 40, "size_min": 0.1, "sync": false
}
}, "line_linked": { "enable": true, "distance": 150, "color": "#ffffff", "opacity": 0.4, "width": 1
}, "move": { "enable": true, "speed": 6, "direction": "none", "random": false, "straight": false, "out_mode": "out", "bounce": false, "attract": { "enable": false, "rotateX": 600, "rotateY": 1200
}
}
}, "interactivity": { "detect_on": "canvas", "events": { "onhover": { "enable": true, "mode": "grab"
}, "onclick": { "enable": true, "mode": "push"
}, "resize": true
}, "modes": { "grab": { "distance": 140, "line_linked": { "opacity": 1
}
}, "bubble": { "distance": 400, "size": 40, "duration": 2, "opacity": 8, "speed": 3
}, "repulse": { "distance": 200, "duration": 0.4
}, "push": { "particles_nb": 4
}, "remove": { "particles_nb": 2
}
}
}, "retina_detect": true})
ie浏览器中有自带的切换效果可供调用;其它浏览器的话得自己写程序定位,如淡入淡出可以利用设置css的opacity属性实现;
百叶窗可以利用程序生成N个div,每个div的背景图为你要加载的图,然后设置好每个div的位置即可
1、你的那段放在<body></body>之间2、要把文章内容放在<p id="ccon"></div>中间,并接在你那段后面;
2、再就是将这段代码放到<head></head>之间
<script language="javascript">
//保存背景颜色和字号
function setSz()
{
var va = document.getElementById("bjColor").value
setCookie("bjColor", va, 30)
va = document.getElementById("wzSize").value
setCookie("wzSize", va, 30)
va = document.getElementById("wzColor").value
setCookie("wzColor", va, 30)
va = document.getElementById("gd").value
setCookie("gd", va, 30)
alert("保存成功!")
return
}
//设置背景颜色和字号
function getSz()
{
var bjColor = getCookie('bjColor')
var wzSize = getCookie('wzSize')
var wzColor = getCookie('wzColor')
var gd = getCookie('gd')
if(bjColor != null)
{
document.getElementById("ccon").style.background=bjColor
setSelect(bjColor,"bjColor")
}
if(wzSize != null)
{
document.getElementById("ccon").style.fontSize=wzSize
setSelect(wzSize,"wzSize")
}
if(wzColor != null)
{
document.getElementById("ccon").style.color=wzColor
setSelect(wzColor,"wzColor")
}
if(gd != null)
{
SetScrollValue(gd)
setSelect(gd,"gd")
}
}
/*
* 设置滚动速度
*/
var currentpos,timer
var scrollValue = 100
function SetScrollValue(value)
{
scrollValue = value * 20
}
function initialize()
{
timer = window.setInterval("scrollwindow()",scrollValue)
}
function sc()
{
clearInterval(timer)
}
function scrollwindow()
{
currentpos = document.documentElement.scrollTop
window.scroll(0,++currentpos)
window.status = currentpos
if (currentpos != document.documentElement.scrollTop) sc()
}
document.ondblclick = function()
{
initialize()
}
document.onmousedown = function()
{
sc()
}
</script>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)