纯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: #0f0c29;
            background: linear-gradient(to bottom, #0f0c29, #302b63, #24243e);
            overflow: hidden;
            font-family: Arial, sans-serif;
            perspective: 1000px;
        }

        .atom {
            position: relative;
            width: 300px;
            height: 300px;
            transform-style: preserve-3d;
            animation: rotateAtom 20s infinite linear;
        }

        .nucleus {
            position: absolute;
            width: 60px;
            height: 60px;
            background: radial-gradient(circle, #ff0a54, #ff477e);
            border-radius: 50%;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            box-shadow: 0 0 30px #ff0a54;
        }

        .orbit {
            position: absolute;
            width: 100%;
            height: 100%;
            border: 2px solid rgba(255, 255, 255, 0.1);
            border-radius: 50%;
            transform-style: preserve-3d;
        }

        .electron {
            position: absolute;
            width: 15px;
            height: 15px;
            background: radial-gradient(circle, #00f5d4, #00bbf9);
            border-radius: 50%;
            top: 0;
            left: 50%;
            transform: translateX(-50%);
            box-shadow: 0 0 15px #00f5d4;
        }

        /* 轨道1 */
        .orbit-1 {
            transform: rotateX(70deg) rotateY(10deg);
            animation: orbit1 8s infinite linear;
        }

        .orbit-1 .electron {
            animation: electron1 8s infinite linear;
        }

        /* 轨道2 */
        .orbit-2 {
            transform: rotateX(10deg) rotateY(70deg);
            animation: orbit2 12s infinite linear reverse;
        }

        .orbit-2 .electron {
            animation: electron2 12s infinite linear reverse;
        }

        /* 轨道3 */
        .orbit-3 {
            transform: rotateX(50deg) rotateY(50deg);
            animation: orbit3 15s infinite linear;
        }

        .orbit-3 .electron {
            animation: electron3 15s infinite linear;
        }

        /* 动画定义 */
        @keyframes rotateAtom {
            0% {
                transform: rotateX(0) rotateY(0) rotateZ(0);
            }
            100% {
                transform: rotateX(360deg) rotateY(360deg) rotateZ(360deg);
            }
        }

        @keyframes orbit1 {
            0% {
                transform: rotateX(70deg) rotateY(10deg) rotateZ(0);
            }
            100% {
                transform: rotateX(70deg) rotateY(10deg) rotateZ(360deg);
            }
        }

        @keyframes electron1 {
            0% {
                transform: translateX(-50%) rotateZ(0) translateY(-150px);
            }
            100% {
                transform: translateX(-50%) rotateZ(360deg) translateY(-150px);
            }
        }

        @keyframes orbit2 {
            0% {
                transform: rotateX(10deg) rotateY(70deg) rotateZ(0);
            }
            100% {
                transform: rotateX(10deg) rotateY(70deg) rotateZ(360deg);
            }
        }

        @keyframes electron2 {
            0% {
                transform: translateX(-50%) rotateZ(0) translateY(-150px);
            }
            100% {
                transform: translateX(-50%) rotateZ(360deg) translateY(-150px);
            }
        }

        @keyframes orbit3 {
            0% {
                transform: rotateX(50deg) rotateY(50deg) rotateZ(0);
            }
            100% {
                transform: rotateX(50deg) rotateY(50deg) rotateZ(360deg);
            }
        }

        @keyframes electron3 {
            0% {
                transform: translateX(-50%) rotateZ(0) translateY(-150px);
            }
            100% {
                transform: translateX(-50%) rotateZ(360deg) translateY(-150px);
            }
        }

        /* 背景粒子 */
        .particle {
            position: absolute;
            width: 3px;
            height: 3px;
            background: rgba(255, 255, 255, 0.5);
            border-radius: 50%;
            animation: floatParticle linear infinite;
        }

        @keyframes floatParticle {
            0% {
                transform: translateY(0) translateX(0);
                opacity: 0;
            }
            10% {
                opacity: 1;
            }
            90% {
                opacity: 1;
            }
            100% {
                transform: translateY(-100vh) translateX(100px);
                opacity: 0;
            }
        }

        /* 版权信息 */
        .footer {
            position: absolute;
            bottom: 20px;
            right: 20px;
            color: rgba(255, 255, 255, 0.5);
            font-size: 12px;
        }

        .footer a {
            color: #00f5d4;
            text-decoration: none;
        }

        .footer a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="atom">
        <!-- 原子核 -->
        <div class="nucleus"></div>
        
        <!-- 电子轨道1 -->
        <div class="orbit orbit-1">
            <div class="electron"></div>
        </div>
        
        <!-- 电子轨道2 -->
        <div class="orbit orbit-2">
            <div class="electron"></div>
        </div>
        
        <!-- 电子轨道3 -->
        <div class="orbit orbit-3">
            <div class="electron"></div>
        </div>
    </div>
    
    <!-- 背景粒子 -->
    <div id="particles"></div>
    
 

    <script>
        // 创建背景粒子
        const particlesContainer = document.getElementById('particles');
        const particleCount = 50;
        
        for (let i = 0; i < particleCount; i++) {
            const particle = document.createElement('div');
            particle.classList.add('particle');
            
            // 随机位置
            const left = Math.random() * 100;
            const top = Math.random() * 100 + 100; // 从屏幕底部开始
            
            // 随机大小
            const size = Math.random() * 3 + 1;
            
            // 随机动画时间和延迟
            const duration = Math.random() * 20 + 10;
            const delay = Math.random() * 10;
            
            particle.style.left = `${left}%`;
            particle.style.top = `${top}%`;
            particle.style.width = `${size}px`;
            particle.style.height = `${size}px`;
            particle.style.animationDuration = `${duration}s`;
            particle.style.animationDelay = `-${delay}s`;
            
            particlesContainer.appendChild(particle);
        }
    </script>
</body>
</html>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值