蜘蛛网特效

<!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>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            background-color: #111;
            min-height: 100vh;
            overflow: hidden;
            font-family: 'Arial', sans-serif;
            color: #ddd;
        }
        
        .container {
            position: relative;
            width: 100%;
            height: 100vh;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            z-index: 10;
            text-align: center;
            padding: 20px;
        }
        
        h1 {
            font-size: 3rem;
            margin-bottom: 20px;
            color: #f0f0f0;
            text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
        }
        
        p {
            font-size: 1.2rem;
            margin-bottom: 30px;
            color: #aaa;
            max-width: 600px;
            line-height: 1.6;
        }
        
        .link-btn {
            display: inline-block;
            padding: 12px 30px;
            background: linear-gradient(45deg, #8b0000, #660000);
            color: white;
            text-decoration: none;
            border-radius: 50px;
            font-weight: bold;
            font-size: 1.1rem;
            transition: all 0.3s ease;
            box-shadow: 0 5px 15px rgba(139, 0, 0, 0.4);
            margin-top: 20px;
        }
        
        .link-btn:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 25px rgba(139, 0, 0, 0.6);
        }
        
        .footer {
            position: fixed;
            bottom: 20px;
            width: 100%;
            text-align: center;
            color: #666;
            font-size: 0.9rem;
            z-index: 10;
        }
        
        .footer a {
            color: #8b0000;
            text-decoration: none;
            font-weight: bold;
        }
        
        .footer a:hover {
            text-decoration: underline;
        }
        
        /* 蜘蛛网样式 */
        .web {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 1;
        }
        
        .web-line {
            position: absolute;
            background: rgba(200, 200, 200, 0.3);
            transform-origin: center center;
        }
        
        /* 蜘蛛样式 */
        .spider {
            position: absolute;
            z-index: 2;
            transition: all 0.5s ease;
        }
        
        /* 蜘蛛网震动动画 */
        @keyframes web-shake {
            0%, 100% {
                transform: translate(0, 0);
            }
            25% {
                transform: translate(-2px, -2px);
            }
            50% {
                transform: translate(2px, 2px);
            }
            75% {
                transform: translate(-1px, 1px);
            }
        }
        
        /* 点击效果 */
        .click-effect {
            position: absolute;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.2);
            transform: translate(-50%, -50%);
            pointer-events: none;
            animation: ripple 1s ease-out forwards;
            z-index: 3;
        }
        
        @keyframes ripple {
            0% {
                width: 0;
                height: 0;
                opacity: 0.8;
            }
            100% {
                width: 200px;
                height: 200px;
                opacity: 0;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>蜘蛛网特效</h1>
        <p>这是一个逼真的蜘蛛网特效,蜘蛛会在网上随机爬行,点击页面会使蜘蛛网震动!</p>

    </div>
    
    <div class="footer">

    </div>

    <script>
        // 创建蜘蛛网
        function createSpiderWeb() {
            const web = document.createElement('div');
            web.className = 'web';
            document.body.appendChild(web);
            
            const centerX = window.innerWidth / 2;
            const centerY = window.innerHeight / 2;
            const radius = Math.min(centerX, centerY) * 0.8;
            const lineCount = 12;
            const circleCount = 5;
            
            // 创建辐射线
            for (let i = 0; i < lineCount; i++) {
                const angle = (i / lineCount) * Math.PI * 2;
                const endX = centerX + Math.cos(angle) * radius;
                const endY = centerY + Math.sin(angle) * radius;
                
                const line = document.createElement('div');
                line.className = 'web-line';
                
                const length = Math.sqrt(Math.pow(endX - centerX, 2) + Math.pow(endY - centerY, 2));
                const lineAngle = Math.atan2(endY - centerY, endX - centerX) * 180 / Math.PI;
                
                line.style.width = `${length}px`;
                line.style.height = '1px';
                line.style.left = `${centerX}px`;
                line.style.top = `${centerY}px`;
                line.style.transform = `rotate(${lineAngle}deg)`;
                
                web.appendChild(line);
            }
            
            // 创建同心圆
            for (let i = 1; i <= circleCount; i++) {
                const circleRadius = radius * (i / circleCount);
                const circle = document.createElement('div');
                circle.className = 'web-line';
                
                circle.style.width = `${circleRadius * 2}px`;
                circle.style.height = `${circleRadius * 2}px`;
                circle.style.left = `${centerX - circleRadius}px`;
                circle.style.top = `${centerY - circleRadius}px`;
                circle.style.borderRadius = '50%';
                circle.style.border = '1px solid rgba(200, 200, 200, 0.3)';
                
                web.appendChild(circle);
            }
            
            return web;
        }
        
        // 创建蜘蛛
        function createSpider(web) {
            const spider = document.createElement('div');
            spider.className = 'spider';
            spider.innerHTML = '🕷️';
            spider.style.fontSize = '24px';
            document.body.appendChild(spider);
            
            // 初始位置在网中心
            const centerX = window.innerWidth / 2;
            const centerY = window.innerHeight / 2;
            spider.style.left = `${centerX}px`;
            spider.style.top = `${centerY}px`;
            
            // 蜘蛛移动函数
            function moveSpider() {
                const radius = Math.min(centerX, centerY) * 0.8;
                const angle = Math.random() * Math.PI * 2;
                const distance = Math.random() * radius;
                
                const targetX = centerX + Math.cos(angle) * distance;
                const targetY = centerY + Math.sin(angle) * distance;
                
                spider.style.left = `${targetX}px`;
                spider.style.top = `${targetY}px`;
                
                // 随机决定下次移动时间
                setTimeout(moveSpider, Math.random() * 3000 + 2000);
            }
            
            // 开始移动
            setTimeout(moveSpider, 1000);
            
            return spider;
        }
        
        // 点击效果
        function createClickEffect(x, y) {
            const effect = document.createElement('div');
            effect.className = 'click-effect';
            effect.style.left = `${x}px`;
            effect.style.top = `${y}px`;
            document.body.appendChild(effect);
            
            setTimeout(() => {
                effect.remove();
            }, 1000);
        }
        
        // 初始化特效
        window.addEventListener('load', () => {
            const web = createSpiderWeb();
            const spider = createSpider(web);
            
            // 点击震动蜘蛛网
            document.addEventListener('click', (e) => {
                createClickEffect(e.clientX, e.clientY);
                
                // 震动蜘蛛网
                web.style.animation = 'web-shake 0.5s';
                setTimeout(() => {
                    web.style.animation = '';
                }, 500);
                
                // 蜘蛛受到惊吓移动
                const angle = Math.atan2(e.clientY - parseFloat(spider.style.top), 
                                    e.clientX - parseFloat(spider.style.left));
                const distance = 50;
                
                const newX = parseFloat(spider.style.left) + Math.cos(angle + Math.PI) * distance;
                const newY = parseFloat(spider.style.top) + Math.sin(angle + Math.PI) * distance;
                
                spider.style.left = `${newX}px`;
                spider.style.top = `${newY}px`;
            });
        });
        
        // 响应窗口大小变化
        window.addEventListener('resize', () => {
            document.querySelector('.web')?.remove();
            document.querySelector('.spider')?.remove();
            const web = createSpiderWeb();
            createSpider(web);
        });
    </script>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值