本文最后更新于160 天前,其中的信息可能已经过时,如有错误请发送邮件到jimmy6646az@outlook.com
HTML
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>聚光灯</title>
<!-- 将 rel 属性值改为 stylesheet -->
<link rel="stylesheet" href="css/聚光灯.css" />
</head>
<body>
<h1>Aeon.wiki</h1>
</body>
</html>
CSS
* {
padding: 0;
margin: 0;
}
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #222;
}
h1 {
position: relative;
/* 1rem=16px */
font-size: 8rem;
color: #333;
}
h1:after {
content: 'Aeon.wiki';
position: absolute;
top: 0;
left: 0;
/* 透明色 */
color: transparent;
background-image: linear-gradient(to right, #c23616, #192a56, #00d2d3, yellow,
#6d214f, #2e86de,#4cd137, #e84118);
/* 背景绘制区域,值为text时,给文字设置镂空效果,前提必须是文字颜色为透明色 */
background-clip: text;
/* 谷歌浏览器私有属性 */
-webkit-background-clip: text;
/* 使用裁切方法创建元素的可显示区域 circle表示裁切一个圆形 100px表示圆的直径 0%和50%表示圆心位置 直径和圆心两组值中间用at隔开*/
clip-path: circle(100px at 0% 50%);
-webkit-clip-path: circle(100px at 0% 50%);
animation: move 5s infinite;
}
@keyframes move {
0% {
clip-path: circle(100px at 0% 50%);
-webkit-clip-path: circle(100px at 0% 50%);
}
50% {
clip-path: circle(100px at 100% 50%);
-webkit-clip-path: circle(100px at 100% 50%);
}
100% {
clip-path: circle(100px at 0% 50%);
-webkit-clip-path: circle(100px at 0% 50%);
}
}
实际效果演示:聚光灯
作者:阿阳热爱前端的个人空间-阿阳热爱前端个人主页-哔哩哔哩视频
代码来源:https://github.com/ayangweb/HTML-CSS-case
当您点击页面上的外链进行跳转时,请注意该外链所指向的网站不受我们控制,请谨慎点击并自行评估风险,对于因点击外链所产生的任何损失、纠纷或其他后果,我们不承担相关责任。