<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>文字霓虹灯闪烁效果</title>
<style>
body {
background-color: #000;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
overflow: hidden;
font-family: 'Arial', sans-serif;
}
.neon-container {
text-align: center;
padding: 30px;
}
.neon-text {
color: #fff;
font-size: 5rem;
font-weight: bold;
text-transform: uppercase;
letter-spacing: 8px;
text-shadow:
0 0 10px #fff,
0 0 20px #fff,
0 0 30px #ff00de,
0 0 40px #ff00de,
0 0 70px #ff00de,
0 0 80px #ff00de,
0 0 100px #ff00de,
0 0 150px #ff00de;
animation: flicker 1.5s infinite alternate;
}
.neon-link {
margin-top: 50px;
color: #0ff;
font-size: 1.5rem;
text-decoration: none;
text-shadow:
0 0 5px #fff,
0 0 10px #0ff,
0 0 20px #0ff;
transition: all 0.3s ease;
animation: colorChange 4s infinite;
}
.neon-link:hover {
text-shadow:
0 0 10px #fff,
0 0 20px #0ff,
0 0 30px #0ff;
}
@keyframes flicker {
0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% {
text-shadow:
0 0 10px #fff,
0 0 20px #fff,
0 0 30px #ff00de,
0 0 40px #ff00de,
0 0 70px #ff00de,
0 0 80px #ff00de,
0 0 100px #ff00de,
0 0 150px #ff00de;
}
20%, 24%, 55% {
text-shadow: none;
}
}
@keyframes colorChange {
0% {
color: #0ff;
text-shadow:
0 0 5px #fff,
0 0 10px #0ff,
0 0 20px #0ff;
}
50% {
color: #f0f;
text-shadow:
0 0 5px #fff,
0 0 10px #f0f,
0 0 20px #f0f;
}
100% {
color: #0ff;
text-shadow:
0 0 5px #fff,
0 0 10px #0ff,
0 0 20px #0ff;
}
}
.particles {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
.particle {
position: absolute;
width: 2px;
height: 2px;
background-color: rgba(255, 255, 255, 0.5);
border-radius: 50%;
animation: float linear infinite;
}
@keyframes float {
0% {
transform: translateY(0) translateX(0);
opacity: 1;
}
100% {
transform: translateY(-100vh) translateX(20px);
opacity: 0;
}
}
</style>
</head>
<body>
<div class="particles" id="particles"></div>
<div class="neon-container">
<div class="neon-text">霓虹灯效果</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() * 100;
const posY = Math.random() * 100;
// 随机大小
const size = Math.random() * 3 + 1;
// 随机动画持续时间
const duration = Math.random() * 10 + 5;
// 随机延迟
const delay = Math.random() * 5;
particle.style.left = `${posX}%`;
particle.style.top = `${posY}%`;
particle.style.width = `${size}px`;
particle.style.height = `${size}px`;
particle.style.animationDuration = `${duration}s`;
particle.style.animationDelay = `${delay}s`;
particlesContainer.appendChild(particle);
}
// 随机改变霓虹灯颜色
const neonText = document.querySelector('.neon-text');
const colors = ['#ff00de', '#00ffde', '#deff00', '#ff0000', '#00ff00', '#0000ff'];
setInterval(() => {
const randomColor = colors[Math.floor(Math.random() * colors.length)];
neonText.style.textShadow =
`0 0 10px #fff,
0 0 20px #fff,
0 0 30px ${randomColor},
0 0 40px ${randomColor},
0 0 70px ${randomColor},
0 0 80px ${randomColor},
0 0 100px ${randomColor},
0 0 150px ${randomColor}`;
}, 3000);
</script>
</body>
</html>
文字霓虹灯闪烁效果
于 2025-06-07 15:50:49 首次发布
2782

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



