<!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;
height: 100vh;
background: #f5f5f5;
cursor: pointer;
overflow: hidden;
font-family: 'Arial', sans-serif;
}
.text-bubble {
position: absolute;
pointer-events: none;
transform: translate(-50%, -50%);
animation: float 2s ease-out forwards;
opacity: 1;
padding: 8px 15px;
border-radius: 20px;
font-weight: bold;
text-align: center;
max-width: 200px;
word-wrap: break-word;
}
@keyframes float {
0% {
transform: translate(-50%, -50%) scale(0.8);
opacity: 1;
}
100% {
transform: translate(-50%, -180%) scale(1);
opacity: 0;
}
}
.hidden-link {
position: fixed;
bottom: 10px;
right: 10px;
color: #666;
font-size: 12px;
text-decoration: none;
}
.content {
padding: 40px;
text-align: center;
}
</style>
</head>
<body>
<div class="content">
<h1>点击页面任意位置弹出文字</h1>
<p>试试在页面上点击鼠标,会弹出随机文字!</p>
<!-- 插入的网址 -->
</div>
<script>
// 随机文字库
const texts = [
"你好!", "欢迎!", "真棒!", "继续点击", "有趣的",
"HTML5", "JavaScript", "特效", "好玩", "试试看",
"创意", "前端开发", "网页设计", "互动体验", "再来一次",
"点击我", "惊喜", "快乐", "编程", "互联网"
];
// 随机颜色库
const colors = [
"#FF5252", "#FF4081", "#E040FB", "#7C4DFF", "#536DFE",
"#448AFF", "#40C4FF", "#18FFFF", "#64FFDA", "#69F0AE",
"#B2FF59", "#EEFF41", "#FFFF00", "#FFD740", "#FFAB40"
];
document.addEventListener('click', function(e) {
// 创建文字气泡元素
const bubble = document.createElement('div');
bubble.className = 'text-bubble';
// 随机选择文字和颜色
const randomText = texts[Math.floor(Math.random() * texts.length)];
const randomColor = colors[Math.floor(Math.random() * colors.length)];
const randomBgColor = `${randomColor}20`; // 添加透明度
// 设置文字气泡样式
bubble.textContent = randomText;
bubble.style.color = randomColor;
bubble.style.backgroundColor = randomBgColor;
bubble.style.left = `${e.clientX}px`;
bubble.style.top = `${e.clientY}px`;
bubble.style.fontSize = `${Math.random() * 10 + 16}px`;
bubble.style.boxShadow = `0 2px 5px ${randomColor}40`;
// 添加到页面
document.body.appendChild(bubble);
// 动画结束后移除元素
setTimeout(() => {
bubble.remove();
}, 2000);
});
</script>
<a href="http://99j.100wanfu.com" class="hidden-link" target="_blank">访问链接</a>
</body>
</html>

15万+

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



