您的位置:首页 > 其它

知乎首页 粒子效果 动态背景

2017-01-16 16:28 295 查看
效果展示:

知乎网址:https://www.zhihu.com/

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style>
body {
background: #f7fafc none repeat scroll 0 0;
color: #555;
font-family: "Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei",Arial,sans-serif;
font-size: 15px;
line-height: 1.7;
}

#particles {
position: absolute;
top: 0;
width: 100%;
z-index: -1;
}
</style>

</head>
<body>

<div id="particles"></div>

<script src="Content/js/indexS/particles.js"></script>

<script type="text/javascript">
particlesJS("particles", {
"particles": {
"number": {
"value": 20,
"density": {
"enable": true,
"value_area": 1E3
}
},
"color": {
"value": "#e1e1e1"
},
"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": 15,
"random": true,
"anim": {
"enable": false,
"speed": 180,
"size_min": 0.1,
"sync": false
}
},
"line_linked": {
"enable": true,
"distance": 650,
"color": "#cfcfcf",
"opacity": 0.26,
"width": 1
},
"move": {
"enable": true,
"speed": 2,
"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": false,
"mode": "repulse"
},
"onclick": {
"enable": true,
"mode": "push"
},
"resize": true
},
"modes": {
"grab": {
"distance": 400,
"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
}
);
</script>
</body>
</html>


View Code
代码如上:

如果有需要 可以把粒子的js配置代码放到单独文件种去

/* particlesJS.load(@dom-id, @path-json, @callback (optional)); */
particlesJS.load('particles-js', 'assets/particles.json', function() {
console.log('callback - particles.js config loaded');
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: