按下右侧的“点击预览”按钮能够在当前页面预览,点击连接能够全屏预览。css
https://codepen.io/comehope/pen/jKxyXNhtml
此视频是能够交互的,你能够随时暂停视频,编辑视频中的代码。前端
请用 chrome, safari, edge 打开观看。git
https://scrimba.com/p/pEgDAM/cZ8LNA7github
每日前端实战系列的所有源代码请从 github 下载:web
https://github.com/comehope/front-end-daily-challengeschrome
定义 dom,容器中有一段文本:dom
<p>thanks</p>
居中显示:flex
body { margin: 0; height: 100vh; display: flex; align-items: center; justify-content: center; background-color: black; }
定义文字样式:动画
p { font-size: 20vw; color: white; font-family: sans-serif; text-transform: uppercase; font-weight: bold; }
设置彩虹背景:
p { background-image: linear-gradient( to right, orangered, orange, gold, lightgreen, cyan, dodgerblue, mediumpurple, hotpink, orangered); background-size: 110vw; }
定义动画效果:
p { animation: sliding 30s linear infinite; } @keyframes sliding { to { background-position: -2000vw; } }
最后,把彩虹背景移到文字下面:
p { -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
大功告成!