<!DOCTYPE html>
<html>
  <head>
    <title>火柴人跳舞动画</title>
    <style>
      .container {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
        background-color: #f0f0f0;
      }
      .dancer {
        position: relative;
        width: 300px;
        height: 300px;
      }
      .head {
        position: absolute;
        top: 35px;
        left: 100px;
        width: 100px;
        height: 100px;
        border: 2px solid black;
        border-radius: 50%;
        background-color: #ffe4b5;
      }
      .body {
        position: absolute;
        top: 135px;
        left: 130px;
        width: 40px;
        height: 100px;
        background-color: black;
        transform-origin: bottom center;
        animation: dance 1s ease infinite alternate;
      }
      .arm-left {
        position: absolute;
        top: 145px;
        left: 90px;
        width: 20px;
        height: 60px;
        background-color: black;
        transform-origin: bottom center;
        animation: wave-left 1s ease infinite alternate;
      }
      .arm-right {
        position: absolute;
        top: 145px;
        left: 190px;
        width: 20px;
        height: 60px;
        background-color: black;
        transform-origin: bottom center;
        animation: wave-right 1s ease infinite alternate;
      }
      .leg-left {
        position: absolute;
        top: 235px;
        left: 120px;
        width: 20px;
        height: 80px;
        background-color: black;
        transform-origin: top center;
        animation: kick-left 1s ease infinite alternate;
      }
      .leg-right {
        position: absolute;
        top: 235px;
        left: 160px;
        width: 20px;
        height: 80px;
        background-color: black;
        transform-origin: top center;
        animation: kick-right 1s ease infinite alternate;
      }
      @keyframes dance {
        from {
          transform: rotate(-5deg);
        }
        to {
          transform: rotate(5deg);
        }
      }
      @keyframes wave-left {
        from {
          transform: rotate(20deg);
        }
        to {
          transform: rotate(60deg);
        }
      }
      @keyframes wave-right {
        from {
          transform: rotate(-20deg);
        }
        to {
          transform: rotate(-60deg);
        }
      }
      @keyframes kick-left {
        from {
          transform: rotate(0deg);
        }
        to {
          transform: rotate(-80deg);
        }
      }
      @keyframes kick-right {
        from {
          transform: rotate(0deg);
        }
        to {
          transform: rotate(80deg);
        }
      }
    </style>
  </head>
  <body>
    <div class='container'>
      <div class='dancer'>
        <div class='head'></div>
        <div class='body'></div>
        <div class='arm-left'></div>
        <div class='arm-right'></div>
        <div class='leg-left'></div>
        <div class='leg-right'></div>
      </div>
    </div>
  </body>
</html>

原文地址: https://www.cveoy.top/t/topic/lu9t 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录