<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Dia 30</title>
</head>
<body>
<div class="firework">
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
</div>
<body>
<div class="firework" id="firework1">
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
</div>
<div class="firework" id="firework2">
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
</div>
<div class="firework" id="firework3">
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
<div class="explosion"></div>
</div>
</body>
</html>
HTML
格式化
支持Emmet,输入 p 后按 Tab键试试吧!
<head> ... </head>
<body>
</body>
CSS
格式化
body
{
margin: 0;
padding: 0;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-color: rgb(34, 31, 30);
}
.firework
{
position: absolute;
}
.explosion
{
position: absolute;
left: -2px;
bottom: 0;
width: 4px;
height: 80px;
transform-origin: 50% 100%;
overflow: hidden;
}
.explosion:nth-child(1)
{
transform: rotate(0deg)translateY(-15px);
}
.explosion:nth-child(2)
{
transform: rotate(30deg)translateY(-15px);
}
.explosion:nth-child(3)
{
transform: rotate(60deg)translateY(-15px);
}
.explosion:nth-child(4)
{
transform: rotate(90deg)translateY(-15px);
}
.explosion:nth-child(5)
{
transform: rotate(120deg)translateY(-15px);
}
.explosion:nth-child(6)
{
transform: rotate(150deg)translateY(-15px);
}
.explosion:nth-child(7)
{
transform: rotate(180deg)translateY(-15px);
}
.explosion:nth-child(8)
{
transform: rotate(210deg)translateY(-15px);
}
.explosion:nth-child(9)
{
transform: rotate(240deg)translateY(-15px);
}
.explosion:nth-child(10)
{
transform: rotate(270deg)translateY(-15px);
}
.explosion:nth-child(11)
{
transform: rotate(300deg)translateY(-15px);
}
.explosion:nth-child(12)
{
transform: rotate(330deg)translateY(-15px);
}
.explosion::before
{
content: "";
position: absolute;
left: 0;
right: 0;
top: 100%;
height: 40px;
background-color: rgb(238, 238, 101);
}
@keyframes explosion
{
0%
{
top: 100%;
}
33%, 100%
{
top: -50%;
}
}
#firework1
{
left: 50%;
top: 50%;
transform: scale(1);
}
#firework1 .explosion::before
{
animation: explosion 2s ease-in-out infinite;
}
#firework2
{
left: 40%;
top: 40%;
transform: scale(.7);
}
#firework2 .explosion::before
{
animation: explosion 2s .6s ease-in-out infinite;
}
#firework3
{
left: 60%;
top:60% ;
transform: scale(.4);
}
#firework3 .explosion::before
{
animation: explosion 2s .4s ease-in-out infinite;
}
JS
格式化