当前位置: 首页 > Web前端 > HTML

前端日常实践:59#视频演示如何使用纯CSS制作彩虹背景文字

时间:2023-04-03 00:19:14 HTML

效果预览点击右侧“点击预览”按钮可在当前页面预览,点击链接可全屏预览.https://codepen.io/comehop??e/pen/jKxyXN互动视频本视频为互动视频,您可以随时暂停视频,编辑视频中的代码。请使用chrome、safari、edge打开观看。https://scrimba.com/p/pEgDAM/cZ8LNA7源码下载日常前端实战系列完整源码请到github下载:https://github.com/comehop??e/front-end-daily-challenges代码解释定义dom,容器中有一段文字:

thanks

显示在中间:body{margin:0;高度:100vh;显示:弹性;对齐项目:居中;证明内容:居中;background-color:black;}定义文字样式:p{font-size:20vw;白颜色;字体系列:无衬线;文本转换:大写;font-weight:bold;}设置彩虹背景:p{background-image:linear-gradient(toright,orangered,orange,gold,lightgreen,cyan,dodgerblue,mediopurple,hotpink,orangered);background-size:110vw;}定义动画效果:p{animation:sliding30slinearinfinite;}@keyframessliding{to{background-position:-2000vw;}}最后,将彩虹背景移到文本下方:p{-webkit-background-clip:text;-webkit-text-fill-color:transparent;}大功告成!