<!DOCTYPE html>
<html lang="zh">
<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;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: #000;
overflow: hidden;
font-family: 'Arial', sans-serif;
}
.glow-text {
position: relative;
font-size: 8vw;
font-weight: bold;
color: #fff;
text-transform: uppercase;
letter-spacing: 4px;
text-align: center;
animation: glow 3s ease-in-out infinite alternate;
text-shadow:
0 0 5px #fff,
0 0 10px #fff,
0 0 20px #fff,
0 0 40px #0ff,
0 0 80px #0ff,
0 0 90px #0ff,
0 0 100px #0ff,
0 0 150px #0ff;
}
.glow-text::before {
content: attr(data-text);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
color: #0ff;
filter: blur(15px);
z-index: -1;
animation: blur-animation 4s ease-in-out infinite alternate;
}
.glow-text::after {
content: attr(data-text);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
color: #f0f;
filter: blur(25px);
z-index: -2;
animation: blur-animation-2 5s ease-in-out infinite alternate;
}
@keyframes glow {
0%, 100% {
text-shadow:
0 0 5px #fff,
0 0 10px #fff,
0 0 20px #fff,
0 0 40px #0ff,
0 0 80px #0ff,
0 0 90px #0ff,
0 0 100px #0ff,
0 0 150px #0ff;
}
50% {
text-shadow:
0 0 5px #fff,
0 0 10px #fff,
0 0 20px #fff,
0 0 40px #f0f,
0 0 80px #f0f,
0 0 90px #f0f,
0 0 100px #f0f,
0 0 150px #f0f;
}
}
@keyframes blur-animation {
0%, 100% {
opacity: 0.7;
transform: translate(5px, 5px);
}
50% {
opacity: 0.3;
transform: translate(-5px, -5px);
}
}
@keyframes blur-animation-2 {
0%, 100% {
opacity: 0.5;
transform: translate(-5px, 5px);
}
50% {
opacity: 0.2;
transform: translate(5px, -5px);
}
}
.particles {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -3;
}
.particle {
position: absolute;
background: rgba(255, 255, 255, 0.5);
border-radius: 50%;
animation: float linear infinite;
}
@keyframes float {
to {
transform: translateY(-100vh);
}
}
.hidden-link {
position: absolute;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
color: rgba(255, 255, 255, 0.3);
font-size: 12px;
text-decoration: none;
z-index: 100;
}
</style>
</head>
<body>
<div class="particles" id="particles"></div>
<h1 class="glow-text" data-text="Glowing Text">Glowing Text</h1>
<script>
// 创建粒子背景
const particlesContainer = document.getElementById('particles');
const particleCount = 30;
for (let i = 0; i < particleCount; i++) {
const particle = document.createElement('div');
particle.classList.add('particle');
// 随机大小
const size = Math.random() * 5 + 1;
particle.style.width = `${size}px`;
particle.style.height = `${size}px`;
// 随机位置
particle.style.left = `${Math.random() * 100}%`;
particle.style.top = `${Math.random() * 100}%`;
// 随机透明度
particle.style.opacity = Math.random() * 0.3 + 0.1;
// 随机动画持续时间
const duration = Math.random() * 15 + 10;
particle.style.animationDuration = `${duration}s`;
// 随机延迟
particle.style.animationDelay = `${Math.random() * 10}s`;
particlesContainer.appendChild(particle);
}
</script>
</body>
</html>