js+css实现小人跟随音乐跳舞动画效果代码

代码语言:html

所属分类:动画

代码描述:js+css实现小人跟随音乐跳舞动画效果代码,点击播放音乐开始。

代码标签: js css 小人 跟随 音乐 跳舞 动画

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  
  
  
<style>
body {
            margin: 0;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1);
            background-size: 400% 400%;
            animation: gradientBG 10s ease infinite;
            overflow: hidden;
        }

        .dance-text {
            font-family: 'Arial Black', sans-serif;
            font-size: 4rem;
            color: white;
            text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
            margin-bottom: 50px;
        }

        .dancer {
            position: relative;
            width: 150px;
            height: 200px;
        }

        .dancer-part {
            position: absolute;
            background: white;
            border-radius: 10px;
            box-shadow: 2px 2px 10px rgba(0,0,0,0.2);
        }

        .head {
            width: 60px;
            height: 60px;
            left: 45px;
            top: 0;
            animation: headMove 1s ease-in-out infinite;
        }

        .body {
            width: 20px;
            height: 80px;
            left: 65px;
            top: 60px;
        }

        .arm {
            width: 70px;
            height: 20px;
            top: 70px;
        }

        .left.arm {
            left: -30px;
            transform-origin: right center;
            animation: armSwingLeft 1s ease-in-out infinite;
        }

        .right.arm {
            right: -30px;
            transform-origin: left center;
            animation: armSwingRight 1s ease-in-out infinite;
        }

        .leg {
            width: 20px;
            height: 90px;
            top: 140px;
        }

        .left.leg {
            left: 45px;
            animation: legKickLeft 1.2s ease-in-out infinite;
        }

        .right.leg {
            left: 85px;
            animation: legKickRight 1.2s ease-in-out infinite;
        }

        @keyframes gradientBG {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }

        @keyframes headMove {
            0%, 100% { transform: translateY(0) rotate(0); }
            50% { transform: translateY(-10px) rotate(5deg); }
        }

        @keyframes armSwingLeft {
            0%, 100% { transform: rotate(-45deg); }
            50% { transform: rotate(30deg); }
        }

        @keyframes armSwingRight {
            0%, 100% { transform: rotate(45deg); }
            50% { transform: rotate(-30deg); }
        }

        @keyframes legKickLeft {
            0%, 100% { transform: rotate(0); }
            50% { transform: rotate(20deg); }
        }

        @keyframes legKickRight {
            0%, 100% { transform: rotate(0); }
            50% { transform: rotate(-20deg); }
        }

        .split-char {
            display: inline-block;
            animation: letterJump 0.8s cubic-bezier(0.5, 0, 0.5, 1.5) infinite alternate;
        }

        @keyframes letterJump {
            to {
                transform: translateY(-30px) rotate(360deg);
                color: #ff6b6b;
            }
        }

       /* Nuevos estilos para controles */
        .controls {
            position: fixed;
            top: 20px;
            display: flex;
            gap: 10px;
            z-index: 100;
        }
        
        .style-btn {
            padding: 10px 20px;
            border: none;
            border-radius: 20px;
            background: rgba(255,255,255,0.9);
            cursor: pointer;
            transition: all 0.3s ease;
        }
        
        .style-btn.active {
            background: #ff6b6b;
            color: white;
            transform: scale(1.1);
        }
        
        /* Sistema de partículas */
        #particles {
            position: fixed;
            top: 0;
            left: 0;
            pointer-events: none;
        }
        
        /* Nuevos estilos de baile */
        .dancer.breakdance .head {
            animation: spin 2s linear infinite;
        }
        
        .dancer.ballet .arm {
            animation: balletArms 3s ease-in-out infinite;
        }
        
        .dancer.disco .leg {
            animation: discoLegs 0.5s steps(4).........完整代码请登录后点击上方下载按钮下载查看

网友评论0