<!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, #1a2a6c, #4b6cb7);
overflow: hidden;
font-family: Arial, sans-serif;
}
.scene {
position: relative;
width: 100%;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.title {
color: white;
font-size: 2.5em;
text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
margin-bottom: 30px;
z-index: 10;
}
.mountain {
position: absolute;
bottom: 0;
width: 100%;
height: 300px;
background: linear-gradient(to top, #2c3e50, #4ca1af);
clip-path: polygon(0% 100%, 100% 100%, 100% 30%, 80% 50%, 60% 30%, 40% 50%, 20% 30%, 0% 50%);
z-index: 2;
}
.fog-container {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 3;
}
.fog {
position: absolute;
width: 200%;
height: 200px;
background: rgba(255, 255, 255, 0.15);
border-radius: 100px;
filter: blur(30px);
animation: fogMove 20s linear infinite;
}
.fog:nth-child(1) {
top: 30%;
animation-duration: 25s;
animation-delay: 0s;
height: 150px;
}
.fog:nth-child(2) {
top: 50%;
animation-duration: 20s;
animation-delay: 5s;
height: 180px;
}
.fog:nth-child(3) {
top: 70%;
animation-duration: 30s;
animation-delay: 10s;
height: 200px;
}
.stars {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1;
}
.star {
position: absolute;
background: white;
border-radius: 50%;
animation: twinkle 3s 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;
}
.link {
position: absolute;
bottom: 30px;
left: 50%;
transform: translateX(-50%);
z-index: 10;
}
.link a {
color: white;
background: rgba(0, 0, 0, 0.3);
padding: 10px 20px;
border-radius: 30px;
text-decoration: none;
font-weight: bold;
transition: all 0.3s;
}
.link a:hover {
background: rgba(0, 0, 0, 0.5);
}
@keyframes fogMove {
0% {
transform: translateX(-100%);
}
100% {
transform: translateX(100%);
}
}
@keyframes twinkle {
0% {
opacity: 0.3;
}
100% {
opacity: 1;
}
}
</style>
</head>
<body>
<div class="scene">
<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="mountain"></div>
<div class="fog-container">
<div class="fog"></div>
<div class="fog"></div>
<div class="fog"></div>
</div>
<div class="link">
</div>
</div>
</body>
</html>

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



