纯html烟花庆祝生日
时间: 2023-11-17 16:04:21 浏览: 217
用html写的烟花,过年过节、哄女朋友都可以用
5星 · 资源好评率100%
以下是一个纯HTML实现的生日蛋糕烟花特效的例子:
```html
<!DOCTYPE html>
<html>
<head>
<title>生日快乐</title>
<style>
body {
background-color: #000;
}
#cake {
position: relative;
margin: 0 auto;
width: 300px;
height: 400px;
background-color: #f90;
border-radius: 10px; box-shadow: 0 0 10px #666;
overflow: hidden;
}
#cake:before {
content: '';
position: absolute;
top: -20px;
left: 50px;
width: 200px;
height: 20px;
background-color: #f90;
border-radius: 10px;
transform: rotate(-45deg);
box-shadow: 0 0 10px #666;
}
#candle {
position: absolute;
top: 50px;
left: 130px;
width: 40px;
height: 100px;
background-color: #fff;
border-radius: 20px;
box-shadow: 0 0 10px #666;
z-index: 1;
}
#flame {
position: absolute;
top: -50px;
left: -10px;
width: 60px;
height: 60px;
background-color: #f00;
border-radius: 50%;
box-shadow: 0 0 10px #f00, 0 0 20px #f00, 0 0 30px #f00, 0 0 40px #f00, 0 0 50px #f00, 0 0 60px #f00;
animation: flame 1s infinite;
}
@keyframes flame {
0% {
transform: scale(1);
}
50% {
transform: scale(1.2);
}
100% {
transform: scale(1);
}
}
#fireworks {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: transparent;
z-index: 2;
}
#fireworks:before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: transparent;
z-index: 3;
}
#fireworks:after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: transparent;
z-index: 4;
}
.firework {
position: absolute;
width: 10px;
height: 10px;
background-color: #fff;
border-radius: 50%;
animation: firework 1s infinite;
}
@keyframes firework {
0% {
transform: translate(0, 0) scale(1);
opacity: 1;
}
50% {
transform: translate(0, -100px) scale(2);
opacity: 0.5;
}
100% {
transform: translate(0, -200px) scale(3);
opacity: 0;
}
}
.firework1 {
top: 50px;
left: 50px;
animation-delay: 0s;
}
.firework2 {
top: 100px;
left: 100px;
animation-delay: 0.2s;
}
.firework3 {
top: 150px;
left: 150px;
animation-delay: 0.4s;
}
.firework4 {
top: 200px;
left: 200px;
animation-delay: 0.6s;
}
.firework5 {
top: 250px;
left: 250px;
animation-delay: 0.8s;
}
</style>
</head>
<body>
<div id="cake">
<div id="candle">
<div id="flame"></div>
</div>
<div id="fireworks">
<div class="firework firework1"></div>
<div class="firework firework2"></div>
<div class="firework firework3"></div>
<div class="firework firework4"></div>
<div class="firework firework5"></div>
</div>
</div>
</body>
</html>
```
阅读全文