<!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>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: #0a0a1a;
overflow: hidden;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
font-family: 'Arial', sans-serif;
color: #00f7ff;
}
.container {
position: relative;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.title {
font-size: 3rem;
margin-bottom: 2rem;
text-shadow: 0 0 10px #00f7ff, 0 0 20px #00f7ff;
z-index: 10;
text-align: center;
animation: glow 2s ease-in-out infinite alternate;
}
.link {
color: #00f7ff;
font-size: 1.2rem;
text-decoration: none;
margin-top: 1rem;
z-index: 10;
transition: all 0.3s ease;
}
.link:hover {
text-shadow: 0 0 5px #00f7ff, 0 0 10px #00f7ff;
}
.water {
position: absolute;
width: 200px;
height: 200px;
border-radius: 50%;
background: rgba(0, 247, 255, 0.1);
box-shadow: 0 0 40px rgba(0, 247, 255, 0.5);
animation: ripple 4s infinite;
opacity: 0;
}
.water:nth-child(2) {
animation-delay: 1s;
}
.water:nth-child(3) {
animation-delay: 2s;
}
.water:nth-child(4) {
animation-delay: 3s;
}
.particles {
position: absolute;
width: 100%;
height: 100%;
overflow: hidden;
}
.particle {
position: absolute;
width: 2px;
height: 2px;
background: #00f7ff;
border-radius: 50%;
opacity: 0.7;
animation: float linear infinite;
}
@keyframes ripple {
0% {
transform: scale(0.5);
opacity: 0.7;
}
100% {
transform: scale(3);
opacity: 0;
}
}
@keyframes glow {
from {
text-shadow: 0 0 10px #00f7ff, 0 0 20px #00f7ff;
}
to {
text-shadow: 0 0 15px #00f7ff, 0 0 30px #00f7ff, 0 0 40px #00f7ff;
}
}
@keyframes float {
0% {
transform: translateY(0) translateX(0);
opacity: 0;
}
10% {
opacity: 0.7;
}
100% {
transform: translateY(-1000px) translateX(200px);
opacity: 0;
}
}
/* 创建粒子 */
.create-particles {
position: absolute;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div class="container">
<h1 class="title">科幻水波纹特效</h1>
<div class="water"></div>
<div class="water"></div>
<div class="water"></div>
<div class="water"></div>
<div class="particles" id="particles"></div>
</div>
<script>
// 创建粒子
const particlesContainer = document.getElementById('particles');
const particleCount = 50;
for (let i = 0; i < particleCount; i++) {
const particle = document.createElement('div');
particle.classList.add('particle');
// 随机位置
const posX = Math.random() * window.innerWidth;
const posY = Math.random() * window.innerHeight;
// 随机大小
const size = Math.random() * 3 + 1;
// 随机动画持续时间
const duration = Math.random() * 20 + 10;
// 随机延迟
const delay = Math.random() * 5;
particle.style.left = `${posX}px`;
particle.style.top = `${posY}px`;
particle.style.width = `${size}px`;
particle.style.height = `${size}px`;
particle.style.animationDuration = `${duration}s`;
particle.style.animationDelay = `${delay}s`;
particlesContainer.appendChild(particle);
}
</script>
</body>
</html>