点击弹出文字

<!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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值