<!DOCTYPE html>
<html>
<head>
<style>
body {
overflow: hidden;
}
.firework {
position: absolute;
width: 10px;
height: 10px;
background-color: #FFF;
border-radius: 50%;
animation: firework 3s infinite;
}
@keyframes firework {
0% {
opacity: 1;
transform: scale(1);
background-color: #F00;
}
50% {
opacity: 0;
transform: scale(2);
background-color: #0F0;
}
100% {
opacity: 1;
transform: scale(1);
background-color: #00F;
}
}
</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();
}, 3000);
}
setInterval(createFirework, 500);
</script>
</body>
</html>
如果你想在个人网页上添加彩色烟花动态效果的背景特效,可以使用HTML和CSS来实现。上面是一个简单的示例代码
这段代码会在网页中创建多个彩色烟花元素,并以动画效果在页面中随机移动。每个烟花元素具有不同的颜色和大小变化。你可以将这段代码复制到一个HTML文件中,并在浏览器中打开,即可看到彩色烟花动态效果的背景特效。你也可以根据自己的需要进行修改和调整。