纯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 {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background: linear-gradient(135deg, #1a1a2e, #16213e);
            margin: 0;
            font-family: Arial, sans-serif;
            overflow: hidden;
        }

        .speaker-set {
            display: flex;
            gap: 50px;
        }

        .speaker {
            position: relative;
            width: 150px;
            height: 250px;
            background: #333;
            border-radius: 15px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.5);
            animation: speaker-shake 0.1s infinite alternate;
        }

        .speaker::before {
            content: '';
            position: absolute;
            width: 120px;
            height: 120px;
            background: radial-gradient(circle, #444 0%, #222 70%);
            border-radius: 50%;
            top: 30px;
            left: 15px;
            box-shadow: inset 0 0 15px rgba(0,0,0,0.8);
        }

        .speaker::after {
            content: '';
            position: absolute;
            width: 80px;
            height: 80px;
            background: radial-gradient(circle, #555 0%, #333 70%);
            border-radius: 50%;
            top: 50px;
            left: 35px;
        }

        .sound-waves {
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
        }

        .wave {
            position: absolute;
            width: 10px;
            height: 5px;
            background: rgba(255,255,255,0.3);
            border-radius: 5px;
            animation: sound-wave 1s infinite;
        }

        .wave:nth-child(1) {
            top: 40px;
            left: -20px;
            animation-delay: 0.1s;
        }
        .wave:nth-child(2) {
            top: 60px;
            left: -20px;
            animation-delay: 0.3s;
        }
        .wave:nth-child(3) {
            top: 80px;
            left: -20px;
            animation-delay: 0.5s;
        }
        .wave:nth-child(4) {
            top: 100px;
            left: -20px;
            animation-delay: 0.7s;
        }
        .wave:nth-child(5) {
            top: 120px;
            left: -20px;
            animation-delay: 0.9s;
        }

        .wave:nth-child(6) {
            top: 40px;
            right: -20px;
            animation-delay: 0.1s;
        }
        .wave:nth-child(7) {
            top: 60px;
            right: -20px;
            animation-delay: 0.3s;
        }
        .wave:nth-child(8) {
            top: 80px;
            right: -20px;
            animation-delay: 0.5s;
        }
        .wave:nth-child(9) {
            top: 100px;
            right: -20px;
            animation-delay: 0.7s;
        }
        .wave:nth-child(10) {
            top: 120px;
            right: -20px;
            animation-delay: 0.9s;
        }

        .stand {
            position: absolute;
            width: 30px;
            height: 20px;
            background: #222;
            bottom: -20px;
            left: 60px;
            border-radius: 0 0 5px 5px;
        }

        @keyframes speaker-shake {
            0% {
                transform: translateX(0) translateY(0);
            }
            100% {
                transform: translateX(1px) translateY(1px);
            }
        }

        @keyframes sound-wave {
            0% {
                transform: scaleX(0.5);
                opacity: 0;
            }
            50% {
                transform: scaleX(3);
                opacity: 0.5;
            }
            100% {
                transform: scaleX(0.5);
                opacity: 0;
            }
        }

        /* 插入的链接样式 */
        .custom-link {
            position: fixed;
            bottom: 20px;
            right: 20px;
            color: rgba(255,255,255,0.7);
            text-decoration: none;
            font-size: 14px;
            background: rgba(0,0,0,0.3);
            padding: 8px 15px;
            border-radius: 20px;
            transition: all 0.3s ease;
        }

        .custom-link:hover {
            color: white;
            background: rgba(0,0,0,0.5);
        }
    </style>
</head>
<body>
    <div class="speaker-set">
        <div class="speaker">
            <div class="sound-waves">
                <div class="wave"></div>
                <div class="wave"></div>
                <div class="wave"></div>
                <div class="wave"></div>
                <div class="wave"></div>
                <div class="wave"></div>
                <div class="wave"></div>
                <div class="wave"></div>
                <div class="wave"></div>
                <div class="wave"></div>
            </div>
            <div class="stand"></div>
        </div>
        <div class="speaker">
            <div class="sound-waves">
                <div class="wave"></div>
                <div class="wave"></div>
                <div class="wave"></div>
                <div class="wave"></div>
                <div class="wave"></div>
                <div class="wave"></div>
                <div class="wave"></div>
                <div class="wave"></div>
                <div class="wave"></div>
                <div class="wave"></div>
            </div>
            <div class="stand"></div>
        </div>
    </div>
    
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值