滚筒洗衣机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;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background: #f0f0f0;
            font-family: Arial, sans-serif;
        }
        
        .washing-machine {
            position: relative;
            width: 300px;
            height: 400px;
            background: #e0e0e0;
            border-radius: 15px;
            box-shadow: 0 10px 20px rgba(0,0,0,0.2);
            overflow: hidden;
        }
        
        /* 洗衣机顶部控制面板 */
        .control-panel {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 80px;
            background: #333;
            border-radius: 15px 15px 0 0;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            z-index: 10;
        }
        
        .display {
            width: 80%;
            height: 30px;
            background: #8bc34a;
            border-radius: 5px;
            margin-bottom: 10px;
            display: flex;
            justify-content: center;
            align-items: center;
            color: white;
            font-size: 14px;
            font-weight: bold;
        }
        
        .buttons {
            display: flex;
            gap: 10px;
        }
        
        .button {
            width: 30px;
            height: 30px;
            background: #555;
            border-radius: 50%;
            box-shadow: inset 0 0 5px rgba(0,0,0,0.5);
        }
        
        /* 洗衣机门 */
        .door {
            position: absolute;
            top: 100px;
            left: 50%;
            transform: translateX(-50%);
            width: 180px;
            height: 180px;
            border-radius: 50%;
            background: #333;
            border: 10px solid #555;
            box-shadow: inset 0 0 20px rgba(0,0,0,0.8);
            z-index: 5;
        }
        
        .door-window {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 140px;
            height: 140px;
            border-radius: 50%;
            background: rgba(0, 100, 150, 0.3);
            border: 5px solid rgba(255,255,255,0.2);
            overflow: hidden;
        }
        
        /* 滚筒 */
        .drum {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 120px;
            height: 120px;
            border-radius: 50%;
            background: rgba(0,0,0,0.1);
            border: 5px solid rgba(255,255,255,0.1);
            animation: rotate 10s linear infinite;
        }
        
        /* 衣物 */
        .clothes {
            position: absolute;
            background: white;
            opacity: 0.8;
            animation: clothes-move 5s linear infinite;
        }
        
        .clothes:nth-child(1) {
            width: 20px;
            height: 30px;
            top: 20%;
            left: 30%;
            border-radius: 5px;
            background: #ff5252;
            animation-delay: 0s;
        }
        
        .clothes:nth-child(2) {
            width: 25px;
            height: 25px;
            top: 60%;
            left: 20%;
            border-radius: 50%;
            background: #4caf50;
            animation-delay: 1s;
        }
        
        .clothes:nth-child(3) {
            width: 15px;
            height: 40px;
            top: 40%;
            left: 70%;
            border-radius: 3px;
            background: #2196f3;
            animation-delay: 2s;
        }
        
        .clothes:nth-child(4) {
            width: 30px;
            height: 20px;
            top: 70%;
            left: 60%;
            border-radius: 10px;
            background: #ffeb3b;
            animation-delay: 3s;
        }
        
        /* 洗衣机底部 */
        .base {
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 20px;
            background: #555;
            border-radius: 0 0 15px 15px;
        }
        
        /* 动画 */
        @keyframes rotate {
            0% {
                transform: translate(-50%, -50%) rotate(0deg);
            }
            100% {
                transform: translate(-50%, -50%) rotate(360deg);
            }
        }
        
        @keyframes clothes-move {
            0% {
                transform: rotate(0deg) translateX(0);
            }
            100% {
                transform: rotate(360deg) translateX(20px);
            }
        }
        
        /* 水泡效果 */
        .bubbles {
            position: absolute;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
        }
        
        .bubble {
            position: absolute;
            background: rgba(255,255,255,0.5);
            border-radius: 50%;
            animation: bubble-up 3s infinite;
        }
        
        @keyframes bubble-up {
            0% {
                transform: translateY(0) scale(0.3);
                opacity: 0;
            }
            20% {
                opacity: 0.5;
            }
            100% {
                transform: translateY(-100px) scale(1);
                opacity: 0;
            }
        }
        
        /* 底部链接 */
        .footer-link {
            position: absolute;
            bottom: 20px;
            color: #333;
            text-decoration: none;
            font-size: 14px;
            opacity: 0.7;
            transition: opacity 0.3s;
        }
        
        .footer-link:hover {
            opacity: 1;
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="washing-machine">
        <div class="control-panel">
            <div class="display">洗涤中 00:15</div>
            <div class="buttons">
                <div class="button"></div>
                <div class="button"></div>
                <div class="button"></div>
            </div>
        </div>
        
        <div class="door">
            <div class="door-window">
                <div class="drum">
                    <div class="clothes"></div>
                    <div class="clothes"></div>
                    <div class="clothes"></div>
                    <div class="clothes"></div>
                </div>
                
                <div class="bubbles" id="bubbles"></div>
            </div>
        </div>
        
        <div class="base"></div>
    </div>
    

    <script>
        // 动态生成气泡
        const bubblesContainer = document.getElementById('bubbles');
        
        function createBubble() {
            const bubble = document.createElement('div');
            bubble.classList.add('bubble');
            
            // 随机大小
            const size = Math.random() * 10 + 5;
            bubble.style.width = `${size}px`;
            bubble.style.height = `${size}px`;
            
            // 随机位置
            bubble.style.left = `${Math.random() * 100}%`;
            bubble.style.bottom = '0';
            
            // 随机动画延迟
            bubble.style.animationDelay = `${Math.random() * 2}s`;
            
            bubblesContainer.appendChild(bubble);
            
            // 动画结束后移除气泡
            setTimeout(() => {
                bubble.remove();
            }, 3000);
        }
        
        // 每200毫秒创建一个新气泡
        setInterval(createBubble, 200);
    </script>
</body>
</html>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值