水波纹文字效果动画

效果展示

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%
    );
  }
}

完整代码下载

完整代码下载

相关推荐
问心无愧05135 小时前
ctf show web入门160 161
前端·笔记
李小白666 小时前
第四天-WEB服务器基本原理,IIS服务
运维·服务器·前端
humcomm6 小时前
AI编程时代新前端职位
前端·ai编程
好家伙VCC6 小时前
Web Components主题热切换方案揭秘
java·前端
甲维斯7 小时前
Kimi版超级玛丽效果“惊人”,配额不足5厘米!
前端·人工智能
hboot7 小时前
AI工程师第一课 - Python
前端·后端·python
凉菜凉凉7 小时前
AI时代,被抛弃的前端
前端·ai
console.log('npc')7 小时前
AI前端工程与生成式UI学习路线
前端·人工智能·ui
梦曦i8 小时前
uni-router v1.1.1发布:守卫超时保护+路由监听
前端·uni-app
qq_2518364578 小时前
基于java Web网络订餐系统设计与实现 源码文档
java·开发语言·前端