html写一段烟花代码
时间: 2023-04-01 12:00:54 浏览: 104
跨年烟花代码HTML模板效果
5星 · 资源好评率100%
很高兴回答你的问题。以下是一段简单的 HTML 烟花代码:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>烟花效果</title>
<style>
body {
background-color: black;
}
.firework {
position: absolute;
width: 10px;
height: 10px;
border-radius: 50%;
background-color: white;
animation: explode 1s ease-out forwards;
}
@keyframes explode {
% {
transform: scale(1);
opacity: 1;
}
100% {
transform: scale(10);
opacity: ;
}
}
</style>
</head>
<body>
<script>
function createFirework() {
var firework = document.createElement('div');
firework.className = 'firework';
firework.style.left = Math.random() * window.innerWidth + 'px';
firework.style.top = Math.random() * window.innerHeight + 'px';
document.body.appendChild(firework);
setTimeout(function() {
firework.remove();
}, 100);
}
setInterval(createFirework, 500);
</script>
</body>
</html>
```
希望这个代码对你有所帮助。
阅读全文