效果展示
CSS 知识点
- text-shadow 属性绘制立体文字
- clip-path 属性来绘制水波纹
工具网站
页面整体结构实现
使用多个 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%
);
}
}