• 原森林之家(foresthouse.cn)改为走私范(zousifan.com),只是改个名内容不变。
  • 网站图片自建立开始到19年全部丢失,血的教训时刻备份,多点备份!

纯CSS实现动画变色文字效果

网页特效 2年前 (2022-06-05) 225次浏览 0个评论 扫描二维码
本文最后更新于2022年6月5日,已超过 1 年没有更新,如果文章内容失效,请 反馈 给我们,谢谢!


速度可调单位MS演示中有三个效果一个1600、一个800和200

CSS代码如下

<style name="txiu1">
#txiu1{background-image: linear-gradient(to right, red, orange, yellow, green, blue, yellow, orange, red, orange, yellow, green, yellow, orange, red, green);-webkit-text-fill-color: transparent;-webkit-background-clip: text;-webkit-background-size: 200% 100%;-webkit-animation: txiu1-animation 1600ms infinite linear;}
@-webkit-keyframes txiu1-animation {0%{ background-position: 0 0;} 100% { background-position: -100% 0;}}
</style>

<style name="txiu2">
#txiu2{background-image: linear-gradient(to right, red, orange, yellow, green, blue, yellow, orange, red, orange, yellow, green, yellow, orange, red, green);-webkit-text-fill-color: transparent;-webkit-background-clip: text;-webkit-background-size: 200% 100%;-webkit-animation: txiu1-animation 800ms infinite linear;}
@-webkit-keyframes txiu1-animation {0%{ background-position: 0 0;} 100% { background-position: -100% 0;}}
</style>

<style name="txiu3">
#txiu3{background-image: linear-gradient(to right, red, orange, yellow, green, blue, yellow, orange, red, orange, yellow, green, yellow, orange, red, green);-webkit-text-fill-color: transparent;-webkit-background-clip: text;-webkit-background-size: 200% 100%;-webkit-animation: txiu1-animation 200ms infinite linear;}
@-webkit-keyframes txiu1-animation {0%{ background-position: 0 0;} 100% { background-position: -100% 0;}}
</style>

<style name="txiu4">
#txiu4{background-image: linear-gradient(to right, red, orange, yellow, green, blue, yellow, orange, red, orange, yellow, green, yellow, orange, red, green);-webkit-background-size: 200% 100%;-webkit-animation: txiu1-animation 500ms infinite linear;}
@-webkit-keyframes txiu1-animation {0%{ background-position: 0 0;} 100% { background-position: -100% 0;}}
</style>

Html代码如下

<div id="txiu1">小么小儿郎,背着那书包进学堂;不怕太阳晒,也不怕那风雨狂;1600ms</div>
<div id="txiu2">只怕那先生骂我懒呐,没有学问喔无脸见爹娘 800ms</div>
<div id="txiu3">郎里格郎里格郎里格郎,没有学问喔无脸见爹娘 200ms</div>
<div id="txiu4">小么小儿郎,背着那书包进学堂</div>
演示链接
版权所有丨如未注明 , 均为原创丨本网站采用 BY-NC-SA 协议进行授权 , 转载请注明 出处!
喜欢 (1)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
    仅用来给您发送回复提醒。不会公开!
  • 网址