fancy wipe

2024-11-22

前端

愿望是半个生命,淡漠是半个死亡。——纪伯伦

源码:

https://codepen.io/Chester/details/LYKWMxO

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
<h1 class="fancy-wipe">
<span class="text">
Transference
</span>
<span class="wipe-in">
Transference
</span>
<span class="blur-in">
Transference
</span>
</h1>

<h1 class="fancy-wipe" style="--colors: linear-gradient(90deg, #4ec6f3, #e10fb4)">
<span class="text">
Serendipitous
</span>
<span class="wipe-in">
Serendipitous
</span>
<span class="blur-in">
Serendipitous
</span>
</h1>

<h1 class="fancy-wipe" style="--colors: linear-gradient(
90deg,
rgba(255, 0, 0, 1) 0%,
rgba(255, 154, 0, 1) 10%,
rgba(208, 222, 33, 1) 20%,
rgba(79, 220, 74, 1) 30%,
rgba(63, 218, 216, 1) 40%,
rgba(47, 201, 226, 1) 50%,
rgba(28, 127, 238, 1) 60%,
rgba(95, 21, 242, 1) 70%,
rgba(186, 12, 248, 1) 80%,
rgba(251, 7, 217, 1) 90%,
rgba(255, 0, 0, 1) 100%
);">
<span class="text">
Ostentatious
</span>
<span class="wipe-in">
Ostentatious
</span>
<span class="blur-in">
Ostentatious
</span>
</h1>

css

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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
html {
width: 100%;
height: 100%;
background: #222;
color: white;
}
body {
font-family: Raleway, sans-serif;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
padding: 0;
margin: 0;
}

.fancy-wipe {
margin: 0;
font-weight: 900;
font-size: 6rem;
position: relative;
--duration: 2.5s;
--easing: cubic-bezier(0.45, 0, 0.55, 1);
--colors: linear-gradient(
90deg,
#fff89a,
#cdf2ca,
#a2cdcd,
#d1e8e4,
#cab8ff,
#ff7878,
#ffc898
);
}

.text {
display: block;
padding: 2rem;
color: white;
animation: wipe-in var(--duration) infinite var(--easing);
mask: linear-gradient(to right, white, white 45%, black, 55%, black);
mask-composite: exclude;
mask-mode: luminance;
mask-size: 300% 100%;
mask-position: 100% 0px;
}

.wipe-in {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
padding: 2rem;
background-image: var(--colors);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
animation: wipe-in var(--duration) infinite var(--easing);
mask: linear-gradient(to right, black, black 45%, white 50%, black 52.5%, black);
mask-composite: exclude;
mask-mode: luminance;
mask-size: 300% 100%;
mask-position: 100% 0px;
}

.blur-in {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
padding: 2rem;
background-image: var(--colors);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
animation: wipe-in var(--duration) infinite var(--easing);
mask: linear-gradient(to right, black, black 45%, white 52.5%, black 55%, black);
mask-composite: exclude;
mask-mode: luminance;
mask-size: 300% 100%;
mask-position: 100% 0px;
filter: blur(10px);
}

@keyframes wipe-in {
100% {
mask-position: 0px 0px;
}
}

效果还是不错的