HTML做成一个粒子漩涡特效页面
要在HTML页面上创建粒子漩涡特效,可以使用canvas
元素和JavaScript库,例如particles.js
。以下是一个简单的例子,展示如何集成particles.js
到HTML页面中。
首先,你需要在HTML文件中添加canvas
元素:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Particle Swirl Effect</title>
<style>
canvas {
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
z-index: 1;
}
</style>
</head>
<body>
<canvas id="particles-js"></canvas>
<script src="particles.js"></script>
<script src="app.js"></script>
</body>
</html>
然后,创建app.js
文件,并添加以下内容:
// app.js
particlesJS('particles-js', {
"particles": {
"number": {
"value": 80,
"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.25,
"sync": false
}
},
"size": {
"value": 5,
"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": 2,
"direction": "none",
"random": false,
"straight": false,
"out_mode": "out",
"attract": {
"enable": false,
"rotateX": 600,
评论已关闭