给大家分享一个用CSS 3.0实现的水纹晃动的特效,效果如下:
以下是代码实现,欢迎大家复制粘贴和收藏。
代码语言:javascript复制<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>CSS 3.0实现水纹晃动特效</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: '微软雅黑', sans-serif;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: #000;
}
.container {
position: relative;
}
.container h2 {
position: absolute;
font-size: 20em;
transform: translate(-50%, -50%);
}
.container h2:nth-child(1) {
color: transparent;
-webkit-text-stroke: 2px #03a9f4;
}
.container h2:nth-child(2) {
color: #03a9f4;
animation: animate 4s ease-in-out infinite;
}
@keyframes animate {
0%,
100% {
clip-path: polygon(1% 65%, 32% 75%, 44% 75%, 69% 70%, 86% 62%, 97% 57%, 100% 54%, 100% 99%, 3% 100%, 1% 100%);
}
50% {
clip-path: polygon(1% 73%, 24% 74%, 40% 74%, 66% 59%, 87% 50%, 97% 45%, 100% 43%, 100% 99%, 3% 100%, 1% 100%);
}
}
</style>
</head>
<body>
<div class="container">
<h2>Water</h2>
<h2>Water</h2>
</div>
</body>
</html>