CSS聚光灯效果
AlightYoung 10/29/2020 CSS
# 源码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
}
body{
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-color: #222;
}
h1{
position: relative;
text-transform: uppercase;
color: #333;
font-size: 4rem;
}
h1::after{
position: absolute;
content: 'spotlight';
left: 0;
top:0;
color: transparent;
background-image:linear-gradient(to right,#E64845,#E68545,#E6CB45,#A5E645,#45E668,#45ABE6,#C845E6) ;
/* background-clip: text; */
-webkit-background-clip: text; /* works on chrome */
clip-path: circle(2rem at 0% 50%);
animation: move 5s infinite cubic-bezier(.58,.13,.4,.87);
}
@keyframes move{
0%{
clip-path: circle(2rem at 0% 50%);
}
50%{
clip-path: circle(2rem at 100% 50%);
}
100%{
clip-path: circle(2rem at 0% 50%);
}
}
</style>
</head>
<body>
<h1>spotlight</h1>
</body>
</html>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54