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;
            background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
            height: 100vh;
            overflow: hidden;
            display: flex;
            justify-content: center;
            align-items: center;
            font-family: Arial, sans-serif;
        }
        
        .ice-rink {
            width: 800px;
            height: 500px;
            background: linear-gradient(to bottom, #a8d8ea 0%, #7ab3d0 100%);
            border-radius: 10px;
            position: relative;
            overflow: hidden;
            box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
        }
        
        /* 冰面纹理 */
        .ice-rink::before {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: 
                linear-gradient(90deg, rgba(255,255,255,0.1) 1px, transparent 1px),
                linear-gradient(rgba(255,255,255,0.1) 1px, transparent 1px);
            background-size: 20px 20px;
            opacity: 0.5;
        }
        
        /* 中线 */
        .center-line {
            position: absolute;
            top: 50%;
            left: 0;
            right: 0;
            height: 2px;
            background-color: #fff;
            transform: translateY(-50%);
        }
        
        /* 中圈 */
        .center-circle {
            position: absolute;
            top: 50%;
            left: 50%;
            width: 60px;
            height: 60px;
            border: 2px solid #fff;
            border-radius: 50%;
            transform: translate(-50%, -50%);
        }
        
        /* 球员 */
        .player {
            position: absolute;
            bottom: 100px;
            left: 200px;
            width: 80px;
            height: 120px;
            animation: skate 5s infinite ease-in-out;
        }
        
        .player-body {
            position: absolute;
            width: 50px;
            height: 80px;
            background-color: #ff0000;
            border-radius: 25px 25px 10px 10px;
            bottom: 0;
            left: 15px;
            z-index: 2;
        }
        
        .player-helmet {
            position: absolute;
            width: 40px;
            height: 30px;
            background-color: #000;
            border-radius: 20px 20px 15px 15px;
            top: 0;
            left: 20px;
            z-index: 3;
        }
        
        .player-helmet::before {
            content: "";
            position: absolute;
            width: 30px;
            height: 10px;
            background-color: #ccc;
            top: 5px;
            left: 5px;
            border-radius: 5px;
        }
        
        .player-stick {
            position: absolute;
            width: 80px;
            height: 10px;
            background-color: #8B4513;
            bottom: 20px;
            left: -20px;
            transform-origin: right center;
            transform: rotate(-20deg);
            z-index: 1;
            animation: swing-stick 2s infinite;
        }
        
        .player-stick::after {
            content: "";
            position: absolute;
            width: 30px;
            height: 5px;
            background-color: #8B4513;
            bottom: -5px;
            left: 0;
            transform: rotate(20deg);
        }
        
        .player-skate-left, .player-skate-right {
            position: absolute;
            width: 20px;
            height: 30px;
            background-color: #000;
            bottom: -15px;
            border-radius: 0 0 10px 10px;
        }
        
        .player-skate-left {
            left: 10px;
            animation: skate-left 0.5s infinite alternate;
        }
        
        .player-skate-right {
            left: 40px;
            animation: skate-right 0.5s infinite alternate;
        }
        
        /* 冰球 */
        .puck {
            position: absolute;
            width: 20px;
            height: 10px;
            background-color: #000;
            border-radius: 10px;
            bottom: 110px;
            left: 300px;
            animation: slide 5s infinite linear;
            z-index: 4;
        }
        
        .puck::before {
            content: "";
            position: absolute;
            width: 16px;
            height: 6px;
            background-color: #fff;
            border-radius: 8px;
            top: 2px;
            left: 2px;
        }
        
        /* 动画效果 */
        @keyframes skate {
            0%, 100% {
                transform: translateX(0);
            }
            25% {
                transform: translateX(200px);
            }
            50% {
                transform: translateX(400px);
            }
            75% {
                transform: translateX(200px);
            }
        }
        
        @keyframes swing-stick {
            0%, 100% {
                transform: rotate(-20deg);
            }
            50% {
                transform: rotate(10deg);
            }
        }
        
        @keyframes skate-left {
            0% {
                transform: translateY(0) rotate(0deg);
            }
            100% {
                transform: translateY(-5px) rotate(5deg);
            }
        }
        
        @keyframes skate-right {
            0% {
                transform: translateY(-5px) rotate(-5deg);
            }
            100% {
                transform: translateY(0) rotate(0deg);
            }
        }
        
        @keyframes slide {
            0%, 100% {
                transform: translateX(0) translateY(0);
            }
            10% {
                transform: translateX(50px) translateY(-5px);
            }
            20% {
                transform: translateX(100px) translateY(0);
            }
            30% {
                transform: translateX(150px) translateY(-3px);
            }
            40% {
                transform: translateX(200px) translateY(0);
            }
            50% {
                transform: translateX(250px) translateY(-2px);
            }
            60% {
                transform: translateX(300px) translateY(0);
            }
            70% {
                transform: translateX(350px) translateY(-1px);
            }
            80% {
                transform: translateX(400px) translateY(0);
            }
            90% {
                transform: translateX(450px) translateY(-0.5px);
            }
        }
        
        /* 冰花效果 */
        .ice-spark {
            position: absolute;
            width: 5px;
            height: 5px;
            background-color: white;
            border-radius: 50%;
            opacity: 0;
        }
        
        /* 计分板 */
        .scoreboard {
            position: absolute;
            top: 20px;
            left: 50%;
            transform: translateX(-50%);
            background-color: rgba(0, 0, 0, 0.7);
            color: white;
            padding: 10px 20px;
            border-radius: 5px;
            font-size: 18px;
            text-align: center;
        }
        
        .credit {
            position: absolute;
            bottom: 20px;
            color: #fff;
            font-size: 12px;
            text-align: center;
            width: 100%;
        }
        
        .credit a {
            color: #f39c12;
            text-decoration: none;
        }
    </style>
</head>
<body>
    <div class="ice-rink">
        <div class="center-line"></div>
        <div class="center-circle"></div>
        
        <div class="player">
            <div class="player-helmet"></div>
            <div class="player-body"></div>
            <div class="player-stick"></div>
            <div class="player-skate-left"></div>
            <div class="player-skate-right"></div>
        </div>
        
        <div class="puck"></div>
        
        <div class="scoreboard">CSS3 冰球动画特效</div>
    </div>
    

    
    <script>
        // 创建冰花效果
        const iceRink = document.querySelector('.ice-rink');
        
        function createIceSpark() {
            const spark = document.createElement('div');
            spark.classList.add('ice-spark');
            
            // 随机位置
            const x = Math.random() * 800;
            const y = 100 + Math.random() * 400;
            
            spark.style.left = `${x}px`;
            spark.style.top = `${y}px`;
            
            // 随机大小
            const size = 2 + Math.random() * 3;
            spark.style.width = `${size}px`;
            spark.style.height = `${size}px`;
            
            // 随机动画
            const duration = 1 + Math.random() * 2;
            const delay = Math.random() * 3;
            
            spark.style.animation = `fadeOut ${duration}s ${delay}s forwards`;
            
            iceRink.appendChild(spark);
            
            // 动画结束后移除
            setTimeout(() => {
                spark.remove();
            }, (duration + delay) * 1000);
        }
        
        // 添加CSS动画
        const style = document.createElement('style');
        style.textContent = `
            @keyframes fadeOut {
                0% {
                    opacity: 0.8;
                    transform: scale(1);
                }
                100% {
                    opacity: 0;
                    transform: scale(0.5);
                }
            }
        `;
        document.head.appendChild(style);
        
        // 定期生成冰花
        setInterval(createIceSpark, 100);
    </script>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值