烟花代码html
时间: 2023-06-30 11:15:52 浏览: 112
以下是一段简单的HTML代码,可以在网页中显示一个烟花效果:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>烟花效果</title>
<style>
body {
background: #000;
}
canvas {
position: absolute;
top: 0;
left: 0;
z-index: -1;
}
</style>
</head>
<body>
<canvas id="fireworks"></canvas>
<script src="https://cdn.jsdelivr.net/gh/loktar00/fireworks@1.0.0/fireworks.min.js"></script>
<script>
var fireworks = new Fireworks({
target: 'fireworks',
colors: ['#ffffff', '#ff0000', '#00ff00', '#0000ff'],
minDelay: 1500,
maxDelay: 3000,
minForce: 0.1,
maxForce: 0.3,
numParticles: 50,
clearAlpha: 0.2,
backgroundColor: '#000000'
});
fireworks.start();
</script>
</body>
</html>
```
该代码使用了一个名为Fireworks的JavaScript库来实现烟花效果。您可以将该代码复制到HTML文件中并在浏览器中打开该文件以查看效果。
阅读全文