css抖动特效
2020-03-24 本文已影响0人
冬天的_太阳
抖动.gif
<!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">
<link href="./style.css" rel="stylesheet">
<title>CSS 波浪文本动画特效</title>
<link>
<style>
* {
margin: 0;
padding: 0;
font-family: "微软雅黑"
}
body {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
background: #000;
}
.wavy {
position: relative;
/* box-reflect: 倒影特效: 倒影方向:below指定倒影在对象的下边; offset定义反射偏移的距离 ; 定义遮罩层*/
-webkit-box-reflect: below -12px linear-gradient(transparent, rgba(0, 0, 0, 0.2))
}
.wavy span {
--color: red;
position: relative;
display: inline-block;
color: #fff;
font-size: 2em;
animation: animate 1s ease-in-out infinite;
/* css中定义变量: --color
css中使用变量: var(--color)
*/
/* 每个span延迟0.1s 触发动画事件 */
animation-delay: calc(.1s*var(--i));
}
@keyframes animate {
/* 主要是 */
0% {
transform: translateY(0px)
}
10% {
transform: translateY(-10px);
}
20% {
transform: translateY(-24px)
}
40%,
100% {
transform: translateY(0px)
}
}
</style>
</head>
<body>
<div class="wavy">
<span style="--i:1">内</span>
<span style="--i:2">容</span>
<span style="--i:3">加</span>
<span style="--i:4">载</span>
<span style="--i:5">中</span>
<span style="--i:6">.</span>
<span style="--i:7">.</span>
<span style="--i:8">.</span>
</div>
</body>
</html>