<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS3孔明灯特效</title>
<style>
body {
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: linear-gradient(to bottom, #000428, #0a1a3a);
overflow: hidden;
font-family: Arial, sans-serif;
}
.container {
position: relative;
width: 100%;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.title {
color: #fff;
font-size: 2.5em;
text-shadow: 0 0 10px rgba(255, 215, 0, 0.7);
margin-bottom: 30px;
z-index: 10;
}
.lantern {
position: absolute;
width: 60px;
height: 80px;
animation: float 15s linear infinite;
}
.lantern:nth-child(1) {
left: 10%;
top: 100%;
animation-delay: 0s;
animation-duration: 20s;
}
.lantern:nth-child(2) {
left: 20%;
top: 100%;
animation-delay: 3s;
animation-duration: 18s;
}
.lantern:nth-child(3) {
left: 30%;
top: 100%;
animation-delay: 6s;
animation-duration: 22s;
}
.lantern:nth-child(4) {
left: 40%;
top: 100%;
animation-delay: 2s;
animation-duration: 17s;
}
.lantern:nth-child(5) {
left: 50%;
top: 100%;
animation-delay: 5s;
animation-duration: 19s;
}
.lantern:nth-child(6) {
left: 60%;
top: 100%;
animation-delay: 1s;
animation-duration: 21s;
}
.lantern:nth-child(7) {
left: 70%;
top: 100%;
animation-delay: 4s;
animation-duration: 16s;
}
.lantern:nth-child(8) {
left: 80%;
top: 100%;
animation-delay: 7s;
animation-duration: 23s;
}
.lantern-body {
position: relative;
width: 100%;
height: 100%;
background: #ff4d4d;
border-radius: 50% 50% 5% 5%;
box-shadow: 0 0 20px #ff8c00,
inset 0 0 10px rgba(255, 255, 255, 0.5);
}
.lantern-body:before {
content: '';
position: absolute;
width: 90%;
height: 10px;
background: #ffcc00;
top: 5px;
left: 5%;
border-radius: 5px;
}
.lantern-body:after {
content: '';
position: absolute;
width: 80%;
height: 15px;
background: #ffcc00;
bottom: -10px;
left: 10%;
border-radius: 0 0 10px 10px;
}
.lantern-light {
position: absolute;
width: 30px;
height: 40px;
background: #ffcc00;
border-radius: 50%;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
box-shadow: 0 0 30px 10px #ffcc00;
animation: flicker 2s infinite alternate;
}
.stars {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
}
.star {
position: absolute;
background: white;
border-radius: 50%;
animation: twinkle 2s infinite alternate;
}
.star:nth-child(1) {
width: 2px;
height: 2px;
top: 20%;
left: 15%;
animation-delay: 0s;
}
.star:nth-child(2) {
width: 3px;
height: 3px;
top: 30%;
left: 80%;
animation-delay: 0.5s;
}
.star:nth-child(3) {
width: 1px;
height: 1px;
top: 60%;
left: 25%;
animation-delay: 1s;
}
.star:nth-child(4) {
width: 2px;
height: 2px;
top: 70%;
left: 70%;
animation-delay: 1.5s;
}
.star:nth-child(5) {
width: 3px;
height: 3px;
top: 40%;
left: 50%;
animation-delay: 0.8s;
}
.moon {
position: absolute;
width: 100px;
height: 100px;
background: #f5f5dc;
border-radius: 50%;
top: 50px;
right: 50px;
box-shadow: 0 0 30px #f5f5dc;
}
.link {
position: absolute;
bottom: 30px;
left: 50%;
transform: translateX(-50%);
z-index: 10;
}
.link a {
color: white;
background: rgba(255, 140, 0, 0.7);
padding: 10px 20px;
border-radius: 30px;
text-decoration: none;
font-weight: bold;
transition: all 0.3s;
}
.link a:hover {
background: rgba(255, 140, 0, 0.9);
box-shadow: 0 0 15px rgba(255, 140, 0, 0.7);
}
@keyframes float {
0% {
transform: translateY(0) rotate(0deg);
opacity: 0;
}
10% {
opacity: 1;
}
90% {
opacity: 1;
}
100% {
transform: translateY(-100vh) rotate(10deg);
opacity: 0;
}
}
@keyframes flicker {
0% {
opacity: 0.8;
box-shadow: 0 0 30px 10px #ffcc00;
}
100% {
opacity: 1;
box-shadow: 0 0 40px 15px #ffcc00;
}
}
@keyframes twinkle {
0% {
opacity: 0.3;
}
100% {
opacity: 1;
}
}
</style>
</head>
<body>
<div class="container">
<h1 class="title">夜空孔明灯</h1>
<div class="stars">
<div class="star"></div>
<div class="star"></div>
<div class="star"></div>
<div class="star"></div>
<div class="star"></div>
</div>
<div class="moon"></div>
<div class="lantern">
<div class="lantern-body">
<div class="lantern-light"></div>
</div>
</div>
<div class="lantern">
<div class="lantern-body">
<div class="lantern-light"></div>
</div>
</div>
<div class="lantern">
<div class="lantern-body">
<div class="lantern-light"></div>
</div>
</div>
<div class="lantern">
<div class="lantern-body">
<div class="lantern-light"></div>
</div>
</div>
<div class="lantern">
<div class="lantern-body">
<div class="lantern-light"></div>
</div>
</div>
<div class="lantern">
<div class="lantern-body">
<div class="lantern-light"></div>
</div>
</div>
<div class="lantern">
<div class="lantern-body">
<div class="lantern-light"></div>
</div>
</div>
<div class="lantern">
<div class="lantern-body">
<div class="lantern-light"></div>
</div>
</div>
<div class="link">
</div>
</div>
</body>
</html>

1万+

被折叠的 条评论
为什么被折叠?



