<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LED文字展示效果</title>
<style>
body {
background-color: #000;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
overflow: hidden;
font-family: Arial, sans-serif;
}
.led-container {
background-color: #111;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
}
.led-text {
color: #0f0;
font-size: 48px;
font-weight: bold;
text-shadow: 0 0 10px #0f0;
letter-spacing: 5px;
animation: blink 0.5s infinite alternate;
}
@keyframes blink {
from {
opacity: 0.8;
text-shadow: 0 0 5px #0f0;
}
to {
opacity: 1;
text-shadow: 0 0 15px #0f0;
}
}
.link {
color: #0f0;
text-align: center;
margin-top: 20px;
font-size: 14px;
text-decoration: none;
display: block;
}
.link:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="led-container">
<div class="led-text" id="ledDisplay">欢迎光临</div>
</div>
<script>
const messages = [
"欢迎光临",
"LED效果展示",
"动态文字变化",
"HTML+CSS+JS",
"感谢访问"
];
const ledElement = document.getElementById('ledDisplay');
let currentIndex = 0;
function changeMessage() {
ledElement.style.animation = 'none';
ledElement.offsetHeight; // 触发重绘
ledElement.style.animation = 'blink 0.5s infinite alternate';
ledElement.textContent = messages[currentIndex];
currentIndex = (currentIndex + 1) % messages.length;
}
// 初始显示
changeMessage();
// 每3秒切换一次消息
setInterval(changeMessage, 3000);
// 添加随机颜色变化效果
setInterval(() => {
const hue = Math.floor(Math.random() * 60) + 90; // 绿色到黄色范围
ledElement.style.color = `hsl(${hue}, 100%, 50%)`;
ledElement.style.textShadow = `0 0 10px hsl(${hue}, 100%, 50%)`;
}, 5000);
</script>
</body>
</html>