水波纹文字效果动画

效果展示

CSS 知识点

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

工具网站

CSS clip-path maker 效果编辑器

页面整体结构实现

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

html 复制代码
<div class="liquid">
  <h2>Water</h2>
  <h2>Water</h2>
  <h2>Water</h2>
  <h2>Water</h2>
</div>

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

css 复制代码
.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值后复制过来,在结合动画来实现水波纹的效果。

css 复制代码
.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%
    );
  }
}

完整代码下载

完整代码下载

相关推荐
烤麻辣烫1 分钟前
正则表达式快速掌握
前端·javascript·学习·正则表达式·html
长城20243 分钟前
HTML5中可以省略属性值的11个属性总结
前端·html·html5·属性值·省略属性值
木斯佳5 分钟前
前端八股文面经大全:小红书前端一面(2026-2-3)·面经深度解析
前端·状态模式
心之语歌1 小时前
flutter 父子组件互相调用方法,值更新
前端·javascript·flutter
岱宗夫up1 小时前
FastAPI进阶3:云原生架构与DevOps最佳实践
前端·python·云原生·架构·前端框架·fastapi·devops
赛博切图仔1 小时前
告别“打字机”:Generative UI 如何重塑 AI 时代的前端交互?
前端·人工智能·ui
wangbing11251 小时前
开发指南141-类和字节数组转换
java·服务器·前端
~央千澈~1 小时前
抖音弹幕游戏开发之第15集:添加配置文件·优雅草云桧·卓伊凡
java·前端·python
wsad05321 小时前
Shell 脚本中的多行注释和 Here Document 语法解析
前端·chrome
J2虾虾2 小时前
Vite前端项目构建
前端