css3实现文字渐变色动画

利用css3background-clip属性:

background-clip: border-box || padding-box || context-box || no-clip || text

1
<div class="title">彩蛋不只是结尾才有</div>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
.title {
font-size: 16px;
background-image: -webkit-linear-gradient(90deg, #4e17df, #fb6bea 25%, #4e17df 50%, #fb6bea 75%, #4e17df);
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
background-size: 100% 600%;
animation: title 10s linear infinite;
}

@keyframes title {
0% {
background-position: 0 0;
}

100% {
background-position: 0 -300%;
}
}
Disqus 加载中...

如果长时间无法加载,请针对 disq.us | disquscdn.com | disqus.com 启用代理