美文网首页CSS特效
水波纹文字效果动画

水波纹文字效果动画

作者: 林中白虎 | 来源:发表于2024-03-25 08:43 被阅读0次

    效果展示

    波纹的文字.png

    CSS 知识点

    • text-shadow 属性绘制立体文字
    • clip-path 属性来绘制水波纹

    工具网站

    CSS clip-path maker 效果编辑器

    页面整体结构实现

    使用多个 H2 标签来实现水波纹的效果实现,然后使用clip-path结合动画属性一起来进行波浪的起伏动画实现。

    <div class="liquid">
      <h2>Water</h2>
      <h2>Water</h2>
      <h2>Water</h2>
      <h2>Water</h2>
    </div>
    

    实现基础文字的效果(带阴影)

    .liquid h2:nth-child(1) {
      color: #fff;
      text-shadow: -2px 2px 0 #183954, -4px 4px 0 #183954, -6px 6px 0 #183954, -8px
          8px 0 #183954, -10px 10px 0 #183954, -10px 10px 0 #183954,
        -12px 12px 0 #183954, -14px 14px 0 #183954, -16px 16px 0 #183954, -18px 18px
          20px rgba(0, 0, 0, 0.5), -18px 18px 30px rgba(0, 0, 0, 0.5), -18px 18px
          50px rgba(0, 0, 0, 0.5), -18px 18px 150px rgba(0, 0, 0, 0.5);
    }
    

    实现水波纹文字动画

    使用CSS clip-path maker 效果编辑器来绘制出波浪的clip-path值后复制过来,在结合动画来实现水波纹的效果。

    .liquid h2:nth-child(2) {
      color: #2196f3;
      opacity: 0.5;
      animation: animate 3s ease-in-out infinite;
    }
    
    .liquid h2:nth-child(3) {
      color: #2196f3;
      opacity: 0.5;
      animation: animate 6s ease-in-out infinite;
    }
    
    .liquid h2:nth-child(4) {
      color: #2196f3;
      animation: animate 4s ease-in-out infinite;
    }
    
    @keyframes animate {
      0%,
      100% {
        clip-path: polygon(
          0 46%,
          16% 45%,
          34% 52%,
          50% 61%,
          68% 65%,
          85% 61%,
          100% 53%,
          100% 100%,
          0 100%
        );
      }
      50% {
        clip-path: polygon(
          0 66%,
          14% 73%,
          34% 76%,
          50% 71%,
          64% 62%,
          79% 55%,
          100% 51%,
          100% 100%,
          0 100%
        );
      }
    }
    

    完整代码下载

    完整代码下载

    相关文章

      网友评论

        本文标题:水波纹文字效果动画

        本文链接:https://www.haomeiwen.com/subject/piclzdtx.html