CSS水波动画

  • 效果图
    在这里插入图片描述
  • 代码
<!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>
    <style>
      * {
      
      
        padding: 0;
        margin: 0;
      }
      .wave-box {
      
      
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        height: 100vh;
        box-sizing: border-box;
      }
      .wave {
      
      
        width: 80px;
        height: 80px;
        border-radius: 50%;
        margin: 30vh 80px 0px;
      }
      .wave::before,
      .wave::after {
      
      
        position: absolute;
        content: "";
        width: 80px;
        height: 80px;
        border-radius: 50%;
        background-color: rgba(241, 34, 30, 0.9);
      }
      .wave::before {
      
      
        animation: scale 2s infinite;
      }
      .wave::after {
      
      
        animation: scale1 2s infinite;
      }
      @keyframes scale {
      
      
        0% {
      
      
          transform: scale(1);
          opacity: 0.9;
        }
        100% {
      
      
          transform: scale(2);
          opacity: 0;
        }
      }
      @keyframes scale1 {
      
      
        0% {
      
      
          transform: scale(1);
          opacity: 0.9;
        }
        100% {
      
      
          transform: scale(3);
          opacity: 0;
        }
      }
      .wave,
      .wave::before,
      .wave::after {
      
      
        background-color: rgba(241, 34, 30, 0.9);
      }
      .wave1,
      .wave1::before,
      .wave1::after {
      
      
        background-color: rgba(0, 221, 254, 0.9);
      }
      .wave2,
      .wave2::before,
      .wave2::after {
      
      
        background-color: rgba(214, 20, 214, 0.9);
      }
      .wave3,
      .wave3::before,
      .wave3::after {
      
      
        background-color: rgba(26, 229, 8, 0.9);
      }
    </style>
  </head>
  <body>
    <div class="wave-box">
      <div class="wave"></div>
      <div class="wave wave1"></div>
      <div class="wave wave2"></div>
      <div class="wave wave3"></div>
    </div>
  </body>
</html>

猜你喜欢

转载自blog.csdn.net/m0_49045925/article/details/120989699
今日推荐