console
<!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 {
margin: 0;
padding: 0;
background: linear-gradient(135deg, #0c142e, #1a2a4f);
overflow: hidden;
font-family: "Microsoft YaHei", sans-serif;
height: 100vh;
position: relative;
color: white;
}
/* ====================
飘字样式 - 已修复为完整穿越
==================== */
.message {
position: absolute;
white-space: nowrap;
font-size: 26px;
font-weight: bold;
text-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
opacity: 0.95;
left: 0;
visibility: hidden; /* 等JS计算完再显示 */
}
/* ====================
雪花容器
==================== */
#snowflakes {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 1;
}
.snowflake {
position: absolute;
background: white;
border-radius: 50%;
opacity: 0.8;
}
/* ====================
圣诞树容器
==================== */
.tree-container {
position: absolute;
bottom: 40px;
right: 40px;
z-index: 10;
text-align: center;
}
.star {
width: 30px;
height: 30px;
background: #FFD700;
position: relative;
transform: rotate(35deg);
margin: 0 auto;
box-shadow: 0 0 15px #FF4500;
animation: twinkle 1s infinite alternate;
}
@keyframes twinkle {
to { opacity: 0.7; box-shadow: 0 0 25px #FFD700; }
}
.tree-layer {
width: 0;
height: 0;
border-left: solid transparent;
border-right: solid transparent;
border-bottom: solid #0a5f20;
margin-left: -40px;
}
.layer1 { border-left-width: 80px; border-right-width: 80px; border-bottom-width: 100px; margin-top: 10px; }
.layer2 { border-left-width: 60px; border-right-width: 60px; border-bottom-width: 80px; margin-top: -60px; }
.layer3 { border-left-width: 40px; border-right-width: 40px; border-bottom-width: 60px; margin-top: -50px; }
.trunk {
width: 25px;
height: 40px;
background: #8B4513;
margin: -10px auto 0 auto;
border-radius: 5px;
}
.gift {
position: absolute;
width: 20px;
height: 20px;
background: #c00;
bottom: 10px;
transform: rotate(45deg);
}
.gift::before {
content: '';
position: absolute;
width: 100%;
height: 4px;
background: #f00;
top: 8px;
left: 0;
}
.decoration {
position: absolute;
width: 10px;
height: 10px;
border-radius: 50%;
animation: blink 2s infinite alternate;
}
@keyframes blink {
0% { transform: scale(0.8); opacity: 0.5; }
100% { transform: scale(1.2); opacity: 1; }
}
@keyframes fall {
0% { transform: translateY(0) rotate(0deg); }
100% { transform: translateY(100vh) rotate(360deg); }
}
</style>
</head>
<body>
<!-- 飘字 -->
<div class="message">�� 郑欣悦圣诞节快乐!愿你平安喜乐~</div>
<div class="message">�� 郑欣悦圣诞节快乐!天天都有好心情!</div>
<div class="message">�� 郑欣悦圣诞节快乐!梦想都闪闪发光!</div>
<div class="message">❄️ 郑欣悦圣诞节快乐!温暖常伴你左右!</div>
<div class="message">�� 郑欣悦圣诞节快乐!未来比星光更璀璨!</div>
<div class="message">❤️ 郑欣悦圣诞节快乐!被爱包围,笑靥如花!</div>
<div class="message">�� 郑欣悦圣诞节快乐!Merry Christmas & Happy New Year!</div>
<!-- 雪花容器 -->
<div id="snowflakes"></div>
<!-- 圣诞树 -->
<div class="tree-container">
<div class="star"></div>
<div class="tree-layer layer1"></div>
<div class="tree-layer layer2"></div>
<div class="tree-layer layer3"></div>
<div class="trunk"></div>
<div class="gift" style="left: 20px;"></div>
<div class="gift" style="left: 50px; background: #00c;"></div>
<div class="gift" style="left: 80px;"></div>
</div>
<script>
// ====================
// 1. 飘字:完整穿越动画
// ====================
document.addEventListener('DOMContentLoaded', function() {
const messages = document.querySelectorAll('.message');
const colors = ['#ff6ec7', '#6effd9', '#ffcc5c', '#ff7bac', '#a0f0ff', '#ff9a6b', '#d47fff'];
messages.forEach((msg, index) => {
msg.style.color = colors[index % colors.length];
msg.style.top = `${Math.random() * (window.innerHeight - 50)}px`;
// 显示元素以获取宽度
msg.style.visibility = 'visible';
const width = msg.offsetWidth;
const totalDistance = window.innerWidth + width;
// 动态创建唯一动画
const animName = `fly_${Date.now()}_${index}`;
const sheet = document.head.appendChild(document.createElement("style")).sheet;
sheet.insertRule(`
@keyframes ${animName} {
from { transform: translateX(${window.innerWidth}px); }
to { transform: translateX(${-totalDistance}px); }
}
`, 0);
const duration = Math.random() * 5 + 5;
const delay = Math.random() * 5;
msg.style.animation = `${animName} ${duration}s linear ${delay}s infinite`;
});
});
// ====================
// 2. 雪花粒子
// ====================
function createSnowflakes() {
const container = document.getElementById('snowflakes');
const count = 120;
for (let i = 0; i < count; i++) {
const flake = document.createElement('div');
flake.className = 'snowflake';
flake.style.width = `${Math.random() * 6 + 2}px`;
flake.style.height = flake.style.width;
flake.style.left = `${Math.random() * 100}%`;
flake.style.opacity = Math.random() * 0.7 + 0.3;
flake.style.animation = `fall ${Math.random() * 10 + 8}s linear ${Math.random() * 10}s infinite`;
container.appendChild(flake);
}
}
// ====================
// 3. 装饰圣诞树
// ====================
function decorateTree() {
const tree = document.querySelector('.tree-container');
const colors = ['#ff0044', '#00ffcc', '#ffff00', '#ff66ff', '#00ccff'];
for (let i = 0; i < 15; i++) {
const light = document.createElement('div');
light.className = 'decoration';
light.style.backgroundColor = colors[Math.floor(Math.random() * colors.length)];
const top = Math.random() * 200 + 40;
let left = 50;
if (top < 100) left = Math.random() * 100 + 30;
else if (top < 160) left = Math.random() * 80 + 40;
else left = Math.random() * 60 + 50;
light.style.top = `${top}px`;
light.style.left = `${left}px`;
light.style.animationDelay = `${Math.random() * 2}s`;
tree.appendChild(light);
}
}
// 启动所有效果
window.addEventListener('load', () => {
createSnowflakes();
decorateTree();
});
</script>
</body>
</html>