css3

css的loading效果

<!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>Document</title>
  </head>
  <body>
    <!-- loading.html -->
    <div class="boxLoading"></div>

    <!-- 音浪.html -->
    <div class="loader">
      <span></span>
      <span></span>
      <span></span>
      <span></span>
      <span></span>
      <span></span>
      <span></span>
      <span></span>
      <span></span>
      <span></span>
      <span></span>
      <span></span>
      <span></span>
      <span></span>
      <span></span>
    </div>

    <!-- 方块对对碰.html -->
    <div class="loading">
      <div class="loading-square"></div>
      <div class="loading-square"></div>
      <div class="loading-square"></div>
      <div class="loading-square"></div>
    </div>

    <style>
      /* loading.css */
      .boxLoading {
        width: 50px;
        height: 50px;
        margin: auto;
        position: absolute;
        left: 0;
        right: 0;
        top: 0;
        bottom: 0;
      }
      .boxLoading:before {
        content: '';
        width: 50px;
        height: 5px;
        background: #fff;
        opacity: 0.7;
        position: absolute;
        top: 59px;
        left: 0;
        border-radius: 50%;
        animation: shadow 0.5s linear infinite;
      }
      .boxLoading:after {
        content: '';
        width: 50px;
        height: 50px;
        background: #e04960;
        animation: animate 0.5s linear infinite;
        position: absolute;
        top: 0;
        left: 0;
        border-radius: 3px;
      }
      @keyframes animate {
        17% {
          border-bottom-right-radius: 3px;
        }
        25% {
          transform: translateY(9px) rotate(22.5deg);
        }
        50% {
          transform: translateY(18px) scale(1, 0.9) rotate(45deg);
          border-bottom-right-radius: 40px;
        }
        75% {
          transform: translateY(9px) rotate(67.5deg);
        }
        100% {
          transform: translateY(0) rotate(90deg);
        }
      }
      @keyframes shadow {
        0%,
        100% {
          transform: scale(1, 1);
        }
        50% {
          transform: scale(1.2, 1);
        }
      }
    </style>

    <style>
      /* 音浪 */
      .loader {
        position: absolute;
        top: 0px;
        bottom: 0px;
        left: 0px;
        right: 0px;
        margin: auto;
        width: 175px;
        height: 100px;
      }
      .loader span {
        display: block;
        background: #e04960;
        width: 7px;
        height: 100%;
        border-radius: 14px;
        margin-right: 5px;
        float: left;
      }
      .loader span:last-child {
        margin-right: 0px;
      }
      .loader span:nth-child(1) {
        animation: load 2.5s 1.4s infinite linear;
      }
      .loader span:nth-child(2) {
        animation: load 2.5s 1.2s infinite linear;
      }
      .loader span:nth-child(3) {
        animation: load 2.5s 1s infinite linear;
      }
      .loader span:nth-child(4) {
        animation: load 2.5s 0.8s infinite linear;
      }
      .loader span:nth-child(5) {
        animation: load 2.5s 0.6s infinite linear;
      }
      .loader span:nth-child(6) {
        animation: load 2.5s 0.4s infinite linear;
      }
      .loader span:nth-child(7) {
        animation: load 2.5s 0.2s infinite linear;
      }
      .loader span:nth-child(8) {
        animation: load 2.5s 0s infinite linear;
      }
      .loader span:nth-child(9) {
        animation: load 2.5s 0.2s infinite linear;
      }
      .loader span:nth-child(10) {
        animation: load 2.5s 0.4s infinite linear;
      }
      .loader span:nth-child(11) {
        animation: load 2.5s 0.6s infinite linear;
      }
      .loader span:nth-child(12) {
        animation: load 2.5s 0.8s infinite linear;
      }
      .loader span:nth-child(13) {
        animation: load 2.5s 1s infinite linear;
      }
      .loader span:nth-child(14) {
        animation: load 2.5s 1.2s infinite linear;
      }
      .loader span:nth-child(15) {
        animation: load 2.5s 1.4s infinite linear;
      }
      @keyframes load {
        0% {
          background: #531430;
          transform: scaleY(0.08);
        }
        50% {
          background: #e04960;

          transform: scaleY(1);
        }
        100% {
          background: #531430;
          transform: scaleY(0.08);
        }
      }
    </style>

    <style>
      /* 方块对对碰 */
      /* loading.css */
      .loader {
        display: block;
        position: relative;
        height: 20px;
        width: 86px;
      }
      .loading-square {
        position: absolute;
        height: 20px;
        width: 20px;
        top: 0;
      }
      .loading-square:nth-child(1) {
        left: 0;
        animation: square1 1.5s linear forwards infinite;
      }
      .loading-square:nth-child(2) {
        left: 22px;
        animation: square2 1.5s linear forwards infinite;
      }
      .loading-square:nth-child(3) {
        left: 44px;
        animation: square3 1.5s linear forwards infinite;
      }
      .loading-square:nth-child(4) {
        left: 66px;
        animation: square4 1.5s linear forwards infinite;
      }
      @keyframes square1 {
        0% {
          background-color: #97c900;
          transform: translate(0, 0);
        }
        9.09091% {
          transform: translate(0, calc(-100% - 2px));
          background-color: #97c900;
        }
        18.18182% {
          transform: translate(calc(100% + 2px), calc(-100% - 2px));
          background-color: #15668a;
        }
        27.27273% {
          transform: translate(calc(100% + 2px), 0);
        }
        100% {
          background-color: #15668a;
          transform: translate(calc(100% + 2px), 0);
        }
      }
      @keyframes square2 {
        0% {
          background-color: #15668a;
          transform: translate(0, 0);
        }
        18.18182% {
          transform: translate(0, 0);
        }
        27.27273% {
          transform: translate(0, calc(100% + 2px));
          background-color: #15668a;
        }
        36.36364% {
          transform: translate(calc(100% + 2px), calc(100% + 2px));
          background-color: #d53a33;
        }
        45.45455% {
          transform: translate(calc(100% + 2px), 0);
        }
        100% {
          background-color: #d53a33;
          transform: translate(calc(100% + 2px), 0);
        }
      }
      @keyframes square3 {
        0% {
          background-color: #d53a33;
          transform: translate(0, 0);
        }
        36.36364% {
          transform: translate(0, 0);
        }
        45.45455% {
          transform: translate(0, calc(-100% - 2px));
          background-color: #d53a33;
        }
        54.54545% {
          transform: translate(calc(100% + 2px), calc(-100% - 2px));
          background-color: #e79c10;
        }
        63.63636% {
          transform: translate(calc(100% + 2px), 0);
        }
        100% {
          background-color: #e79c10;
          transform: translate(calc(100% + 2px), 0);
        }
      }
      @keyframes square4 {
        0% {
          transform: translate(0, 0);
          background-color: #e79c10;
        }
        54.54545% {
          transform: translate(0, 0);
        }
        63.63636% {
          transform: translate(0, calc(100% + 2px));
          background-color: #e79c10;
        }
        72.72727% {
          background-color: #d53a33;
        }
        81.81818% {
          background-color: #15668a;
        }
        90.90909% {
          transform: translate(calc(-300% - 6px), calc(100% + 2px));
          background-color: #97c900;
        }
        100% {
          transform: translate(calc(-300% - 6px), 0);
          background-color: #97c900;
        }
      }
    </style>
  </body>
</html>
上次更新: