3D立体文字动画

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>3D立体文字动画</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            background: linear-gradient(135deg, #1a1a2e, #16213e);
            overflow: hidden;
            font-family: 'Arial', sans-serif;
        }
        
        .container {
            position: relative;
            perspective: 1000px;
        }
        
        .text-3d {
            position: relative;
            font-size: 8vw;
            font-weight: bold;
            color: #fff;
            text-transform: uppercase;
            text-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
            transform-style: preserve-3d;
            animation: rotate 8s infinite linear;
        }
        
        .text-3d span {
            position: relative;
            display: inline-block;
            transform-style: preserve-3d;
        }
        
        .text-3d span::before,
        .text-3d span::after {
            content: attr(data-char);
            position: absolute;
            top: 0;
            left: 0;
            transform-origin: left center;
        }
        
        .text-3d span::before {
            color: rgba(255, 255, 255, 0.3);
            transform: rotateY(40deg);
            z-index: -1;
        }
        
        .text-3d span::after {
            color: rgba(255, 255, 255, 0.1);
            transform: rotateY(70deg);
            z-index: -2;
        }
        
        @keyframes rotate {
            0% {
                transform: rotateY(0deg) rotateX(10deg);
            }
            50% {
                transform: rotateY(180deg) rotateX(10deg);
            }
            100% {
                transform: rotateY(360deg) rotateX(10deg);
            }
        }
        
        .particles {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: -1;
        }
        
        .particle {
            position: absolute;
            background: rgba(255, 255, 255, 0.5);
            border-radius: 50%;
            animation: float linear infinite;
        }
        
        @keyframes float {
            to {
                transform: translateY(-100vh);
            }
        }
        
        .link {
            position: absolute;
            bottom: 20px;
            right: 20px;
            color: rgba(255, 255, 255, 0.5);
            font-size: 12px;
            text-decoration: none;
            transition: color 0.3s;
        }
        
        .link:hover {
            color: #fff;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="text-3d">
            <span data-char="3">3</span>
            <span data-char="D">D</span>
            <span data-char="立">立</span>
            <span data-char="体">体</span>
            <span data-char="文">文</span>
            <span data-char="字">字</span>
        </div>
        <div class="particles" id="particles"></div>

    </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 size = Math.random() * 5 + 1;
            particle.style.width = `${size}px`;
            particle.style.height = `${size}px`;
            
            // 随机位置
            particle.style.left = `${Math.random() * 100}%`;
            particle.style.bottom = `-${size}px`;
            
            // 随机动画持续时间
            const duration = Math.random() * 10 + 5;
            particle.style.animationDuration = `${duration}s`;
            
            // 随机延迟
            particle.style.animationDelay = `${Math.random() * 5}s`;
            
            particlesContainer.appendChild(particle);
        }
        
        // 鼠标移动效果
        document.addEventListener('mousemove', (e) => {
            const container = document.querySelector('.container');
            const xAxis = (window.innerWidth / 2 - e.pageX) / 25;
            const yAxis = (window.innerHeight / 2 - e.pageY) / 25;
            container.style.transform = `rotateY(${xAxis}deg) rotateX(${yAxis}deg)`;
        });
    </script>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值