<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>点击弹出文字</title>
<style>
body {
margin: 0;
padding: 0;
width: 100vw;
height: 100vh;
overflow: hidden;
cursor: pointer;
background-color: #f0f0f0;
font-family: 'Arial', sans-serif;
}
.text-popup {
position: absolute;
font-size: 24px;
font-weight: bold;
pointer-events: none;
animation: textAnimation 1.5s ease-out forwards;
text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
white-space: nowrap;
}
@keyframes textAnimation {
0% {
transform: translateY(0) scale(0.8);
opacity: 0;
}
20% {
opacity: 1;
}
100% {
transform: translateY(-100px) scale(1.2);
opacity: 0;
}
}
.footer {
position: fixed;
bottom: 10px;
width: 100%;
text-align: center;
color: #666;
font-size: 14px;
}
.footer a {
color: #ff3366;
text-decoration: none;
font-weight: bold;
}
.footer a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<script>
// 可自定义的文字列表
const messages = [
"你好!",
"❤️ 爱你 ❤️",
"太棒了!",
"哇塞!",
"惊喜!",
"点我!",
"开心每一天",
"哈哈哈",
"棒极了",
"666"
];
// 颜色列表
const colors = [
'#FF5252', '#FF4081', '#E040FB', '#7C4DFF',
'#536DFE', '#448AFF', '#40C4FF', '#18FFFF',
'#64FFDA', '#69F0AE', '#B2FF59', '#EEFF41',
'#FFFF00', '#FFD740', '#FFAB40', '#FF6E40'
];
document.addEventListener('click', function(e) {
// 创建文字元素
const textPopup = document.createElement('div');
textPopup.className = 'text-popup';
// 随机选择文字和颜色
const randomMessage = messages[Math.floor(Math.random() * messages.length)];
const randomColor = colors[Math.floor(Math.random() * colors.length)];
textPopup.textContent = randomMessage;
textPopup.style.color = randomColor;
// 设置文字位置为点击位置
textPopup.style.left = (e.clientX - 30) + 'px';
textPopup.style.top = (e.clientY - 20) + 'px';
// 添加到页面
document.body.appendChild(textPopup);
// 动画结束后移除元素
setTimeout(() => {
textPopup.remove();
}, 1500);
});
</script>
</body>
</html>
6387

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



