CSS效果之音频播放效果

代码来自互联网改造而来


<!-- run -->
<style>
    :root {
      --h: 30px;
    }
    .container {
      display: flex;
      align-items: flex-end;
      justify-content: flex-start;
      position: relative;
      height: var(--h);
    }
    .container span {
      background: linear-gradient(to top, #f37d39  0%,  #fff 100%);
      width: 4px;
      height: 50%;
      border-radius: calc(var(--h) * 0.2 * 0.5);
      margin-right: 4px;
      animation: loading 0.5s infinite linear;
      animation-delay: calc(0.1s * var(--d));
    }
    .container span:last-child {
      margin-right: 0px;
    }
    @keyframes loading {
      0% {
        background-image: linear-gradient(to right,#FF5E00 0%, #fca572 100%);
        height: 20%;
        border-radius: calc(var(--h) * 0.2 * 0.5);
      }
      50% {
        background-image: linear-gradient(to top,#FF5E00 0%, #f9f1ec 100%);
        height: 80%;
        border-radius: calc(var(--h) * 0.8 * 0.5);
      }
      100% {
        background-image: linear-gradient(to top, #f48d51 0%, #fb8540 100%);
        height: 20%;
        border-radius: calc(var(--h) * 0.2 * 0.5);
      }
    }
  </style>
 <div class="container">
      <span style="--d: 0"></span>
      <span style="--d: 1"></span>
      <span style="--d: 2"></span>
      <span style="--d: 3"></span>
      <span style="--d: 4"></span>
    </div>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>CSS 实现音频loding动画</title>
  </head>
  <style>
    :root {
      --h: 30px;
    }
    .container {
      display: flex;
      align-items: flex-end;
      justify-content: flex-start;
      position: relative;
      height: var(--h);
    }
    .container span {
      background: linear-gradient(to top, #f37d39  0%,  #fff 100%);
      width: 4px;
      height: 50%;
      border-radius: calc(var(--h) * 0.2 * 0.5);
      margin-right: 4px;
      animation: loading 0.5s infinite linear;
      animation-delay: calc(0.1s * var(--d));
    }
    .container span:last-child {
      margin-right: 0px;
    }
    @keyframes loading {
      0% {
        background-image: linear-gradient(to right,#FF5E00 0%, #fca572 100%);
        height: 20%;
        border-radius: calc(var(--h) * 0.2 * 0.5);
      }
      50% {
        background-image: linear-gradient(to top,#FF5E00 0%, #f9f1ec 100%);
        height: 80%;
        border-radius: calc(var(--h) * 0.8 * 0.5);
      }
      100% {
        background-image: linear-gradient(to top, #f48d51 0%, #fb8540 100%);
        height: 20%;
        border-radius: calc(var(--h) * 0.2 * 0.5);
      }
    }
  </style>
  <body>
    <div class="container">
      <span style="--d: 0"></span>
      <span style="--d: 1"></span>
      <span style="--d: 2"></span>
      <span style="--d: 3"></span>
      <span style="--d: 4"></span>
    </div>
  </body>
</html>
posted @ 2023-12-15 21:14  CoderWGB  阅读(187)  评论(0编辑  收藏  举报