这是另一种你不必使用的方法
clip-path
. 只需依靠一个背景色,将覆盖你的文字。你不会有透明度,但你会有更好的支持。
body {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
background-color: #8ce2ea;
margin:0;
}
.reveal-text {
position: relative;
font-size: 10vw;
color: #FFF;
}
.reveal-text::after {
content: "";
position: absolute;
z-index: 999;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-image:
linear-gradient(#f2f98b, #f2f98b),
linear-gradient(#8ce2ea, #8ce2ea);
background-size: 0% 100%, 100% 100%;
background-repeat: no-repeat;
background-position: left, right;
animation: revealer-text 0.8s 2s cubic-bezier(0.0, 0.0, 0.2, 1) forwards;
}
@keyframes revealer-text {
0% {
background-size: 0% 100%, 100% 100%;
background-position: left, right;
}
50% {
background-size: 100% 100%, 0% 100%;
background-position: left, right;
}
51% {
background-size: 100% 100%, 0% 100%;
background-position: right;
}
100% {
background-size: 0% 100%, 0% 100%;
background-position: right;
}
}
<h1 class="reveal-text">
I'm here.
</h1>