CSS3水滴滴落消除特效

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS3水滴滴落消除特效</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d);
            overflow: hidden;
            font-family: 'Arial', sans-serif;
        }
        
        .container {
            position: relative;
            width: 100%;
            height: 100%;
        }
        
        .drop {
            position: absolute;
            width: 20px;
            height: 20px;
            background: rgba(255, 255, 255, 0.8);
            border-radius: 50%;
            animation: drop 3s ease-in infinite;
            box-shadow: 0 0 10px 2px rgba(255, 255, 255, 0.5);
            opacity: 0;
        }
        
        .ripple {
            position: absolute;
            width: 20px;
            height: 20px;
            border: 2px solid rgba(255, 255, 255, 0.8);
            border-radius: 50%;
            animation: ripple 2s ease-out infinite;
            opacity: 0;
        }
        
        @keyframes drop {
            0% {
                transform: translateY(-100px) scale(0.5);
                opacity: 0;
            }
            10% {
                opacity: 1;
            }
            70% {
                opacity: 1;
            }
            80% {
                transform: translateY(calc(100vh - 100px)) scale(0.5);
                opacity: 0;
            }
            100% {
                transform: translateY(calc(100vh - 80px)) scale(0.3);
                opacity: 0;
            }
        }
        
        @keyframes ripple {
            0% {
                transform: scale(0.3);
                opacity: 1;
            }
            100% {
                transform: scale(10);
                opacity: 0;
            }
        }
        
        .footer {
            position: fixed;
            bottom: 20px;
            color: rgba(255, 255, 255, 0.7);
            text-align: center;
            width: 100%;
            font-size: 14px;
            z-index: 100;
        }
        
        .footer a {
            color: white;
            text-decoration: none;
            font-weight: bold;
            transition: text-shadow 0.3s;
        }
        
        .footer a:hover {
            text-shadow: 0 0 10px white;
        }
        
        .title {
            position: fixed;
            top: 20px;
            color: white;
            font-size: 2.5rem;
            text-align: center;
            width: 100%;
            text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
            z-index: 100;
        }
    </style>
</head>
<body>
    <div class="title">水滴滴落特效</div>
    
    <div class="container" id="container">
        <!-- 水滴将通过JavaScript动态添加 -->
    </div>
    
 

    <script>
        // 创建水滴元素
        const container = document.getElementById('container');
        const colors = ['rgba(255,255,255,0.8)', 'rgba(173, 216, 230, 0.8)', 'rgba(135, 206, 250, 0.8)'];
        
        function createDrop() {
            // 创建水滴
            const drop = document.createElement('div');
            drop.className = 'drop';
            
            // 随机位置
            const left = Math.random() * 100;
            drop.style.left = `${left}%`;
            
            // 随机延迟
            const delay = Math.random() * 5;
            drop.style.animationDelay = `${delay}s`;
            
            // 随机大小
            const size = 0.3 + Math.random() * 0.7;
            drop.style.transform = `scale(${size})`;
            
            // 随机颜色
            const color = colors[Math.floor(Math.random() * colors.length)];
            drop.style.background = color;
            drop.style.boxShadow = `0 0 10px 2px ${color.replace('0.8', '0.5')}`;
            
            container.appendChild(drop);
            
            // 创建涟漪效果
            setTimeout(() => {
                const ripple = document.createElement('div');
                ripple.className = 'ripple';
                ripple.style.left = `${left}%`;
                ripple.style.bottom = '20px';
                ripple.style.borderColor = color;
                container.appendChild(ripple);
                
                // 移除元素
                setTimeout(() => {
                    ripple.remove();
                }, 2000);
            }, 3000 - delay * 1000);
            
            // 移除水滴
            setTimeout(() => {
                drop.remove();
            }, 5000);
        }
        
        // 初始创建水滴
        for (let i = 0; i < 20; i++) {
            setTimeout(createDrop, i * 300);
        }
        
        // 持续创建水滴
        setInterval(createDrop, 500);
    </script>
</body>
</html>

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值