<!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 {
margin: 0;
padding: 0;
background-color: #000;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
font-family: Arial, sans-serif;
}
.led-container {
position: relative;
width: 90%;
max-width: 800px;
height: 120px;
background-color: #111;
border-radius: 10px;
box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
overflow: hidden;
padding: 20px;
box-sizing: border-box;
}
.led-display {
position: relative;
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.led-text {
color: #0f0;
font-size: 48px;
font-weight: bold;
text-shadow: 0 0 10px #0f0;
letter-spacing: 5px;
white-space: nowrap;
position: absolute;
animation: scrollText 20s linear infinite;
}
.led-pixels {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
opacity: 0.3;
}
.pixel {
position: absolute;
width: 2px;
height: 2px;
background-color: rgba(0, 255, 0, 0.5);
border-radius: 50%;
}
.link-container {
position: fixed;
bottom: 20px;
right: 20px;
z-index: 1000;
}
.link-container a {
color: #0f0;
text-decoration: none;
font-size: 14px;
background: rgba(0,0,0,0.5);
padding: 5px 10px;
border-radius: 4px;
font-family: monospace;
}
@keyframes scrollText {
0% {
transform: translateX(100%);
}
100% {
transform: translateX(-100%);
}
}
.controls {
position: fixed;
bottom: 20px;
left: 20px;
z-index: 1000;
}
.controls input {
background: #111;
border: 1px solid #0f0;
color: #0f0;
padding: 5px 10px;
width: 300px;
font-family: monospace;
}
.controls button {
background: #0f0;
border: none;
color: #000;
padding: 5px 10px;
margin-left: 5px;
cursor: pointer;
font-weight: bold;
}
</style>
</head>
<body>
<div class="led-container">
<div class="led-pixels" id="ledPixels"></div>
<div class="led-display">
<div class="led-text" id="ledText">欢迎访问</div>
</div>
</div>
<div class="controls">
<input type="text" id="customText" placeholder="输入自定义LED文字...">
<button onclick="updateText()">更新文字</button>
</div>
<script>
// 创建LED像素点效果
function createPixels() {
const container = document.getElementById('ledPixels');
const containerWidth = container.offsetWidth;
const containerHeight = container.offsetHeight;
const pixelCount = Math.floor((containerWidth * containerHeight) / 100);
for (let i = 0; i < pixelCount; i++) {
const pixel = document.createElement('div');
pixel.className = 'pixel';
pixel.style.left = `${Math.random() * 100}%`;
pixel.style.top = `${Math.random() * 100}%`;
pixel.style.opacity = Math.random() * 0.5 + 0.1;
// 添加闪烁动画
const duration = Math.random() * 3 + 1;
pixel.style.animation = `flicker ${duration}s infinite alternate`;
container.appendChild(pixel);
}
}
// 更新LED显示文字
function updateText() {
const customText = document.getElementById('customText').value;
if (customText.trim() !== '') {
document.getElementById('ledText').textContent = customText;
}
}
// 添加闪烁动画关键帧
function addFlickerAnimation() {
const style = document.createElement('style');
style.textContent = `
@keyframes flicker {
0% { opacity: ${Math.random() * 0.5 + 0.1}; }
50% { opacity: ${Math.random() * 0.5 + 0.3}; }
100% { opacity: ${Math.random() * 0.5 + 0.1}; }
}
`;
document.head.appendChild(style);
}
// 初始化
window.onload = function() {
createPixels();
addFlickerAnimation();
// 示例文字自动循环
const texts = [
"传奇私服新区开放 登录即送VIP",
"极品装备 刀刀暴击 上线就送",
"万人同服 重温经典 等你来战",
];
let index = 0;
setInterval(() => {
document.getElementById('ledText').textContent = texts[index];
index = (index + 1) % texts.length;
}, 5000);
};
</script>
</body>
</html>