钻石旋转背景动画特效

<!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 {
            overflow: hidden;
            background: #000;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            font-family: Arial, sans-serif;
        }
        
        .container {
            position: relative;
            width: 100%;
            height: 100vh;
            overflow: hidden;
        }
        
        .diamond {
            position: absolute;
            top: 50%;
            left: 50%;
            width: 20px;
            height: 20px;
            background: rgba(255, 255, 255, 0.5);
            transform: rotate(45deg);
            box-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #fff;
            animation: diamondAnimation 10s linear infinite;
            opacity: 0;
        }
        
        @keyframes diamondAnimation {
            0% {
                transform: rotate(45deg) scale(0.1) translateX(0);
                opacity: 0;
            }
            10% {
                opacity: 1;
            }
            90% {
                opacity: 1;
            }
            100% {
                transform: rotate(405deg) scale(1) translateX(300px);
                opacity: 0;
            }
        }
        
        .content {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            text-align: center;
            color: white;
            z-index: 100;
        }
        
        h1 {
            font-size: 3rem;
            margin-bottom: 20px;
            text-shadow: 0 0 10px #fff, 0 0 20px #fff, 0 0 30px #e60073;
        }
        
        p {
            font-size: 1.2rem;
            margin-bottom: 30px;
        }
        
        a {
            color: #fff;
            text-decoration: none;
            font-size: 1.1rem;
            padding: 10px 20px;
            border: 1px solid #fff;
            border-radius: 5px;
            transition: all 0.3s ease;
        }
        
        a:hover {
            background: rgba(255, 255, 255, 0.2);
            box-shadow: 0 0 10px #fff, 0 0 20px #fff;
        }
    </style>
</head>
<body>
    <div class="container" id="container"></div>
    
    <div class="content">
        <h1>钻石旋转特效</h1>
        <p>这是一个炫酷的钻石旋转背景动画</p>
     
    </div>
    
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const container = document.getElementById('container');
            const colors = ['#ff0000', '#00ff00', '#0000ff', '#ffff00', '#ff00ff', '#00ffff'];
            
            function createDiamonds() {
                const count = 50;
                
                for (let i = 0; i < count; i++) {
                    const diamond = document.createElement('div');
                    diamond.classList.add('diamond');
                    
                    // 随机大小
                    const size = Math.random() * 20 + 5;
                    diamond.style.width = `${size}px`;
                    diamond.style.height = `${size}px`;
                    
                    // 随机颜色
                    const color = colors[Math.floor(Math.random() * colors.length)];
                    diamond.style.background = color;
                    diamond.style.boxShadow = `0 0 10px ${color}, 0 0 20px ${color}`;
                    
                    // 随机位置
                    const angle = Math.random() * Math.PI * 2;
                    const distance = Math.random() * 100 + 50;
                    
                    // 随机动画延迟和持续时间
                    const delay = Math.random() * 5;
                    const duration = Math.random() * 5 + 5;
                    
                    diamond.style.animation = `diamondAnimation ${duration}s linear ${delay}s infinite`;
                    
                    // 初始位置
                    diamond.style.left = `${Math.cos(angle) * distance}px`;
                    diamond.style.top = `${Math.sin(angle) * distance}px`;
                    
                    container.appendChild(diamond);
                }
            }
            
            createDiamonds();
        });
    </script>
</body>
</html>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值