文字流光

coderljw 2024-10-13 CSS
  • Magic
  • 特效
小于 1 分钟

<main>
  <p data-text="前天看到了小兔子,昨天是小鹿,今天是你">
    前天看到了小兔子,昨天是小鹿,今天是你
  </p>
</main>
1
2
3
4
5
main {
  width: 100%;
  height: 400px;
  display: grid;
  place-items: center;
  background-image: radial-gradient(
    farthest-side at 20% 10%,
    #455a64 0%,
    #263238 60%,
    #1a2327 100%
  );
}

p {
  position: relative;
  font-size: 35px;
  user-select: none;
  white-space: nowrap;
  color: transparent;
  background-color: #e8a95b;
  -webkit-background-clip: text;
}

p::before {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
      120deg,
      transparent 0%,
      transparent 4%,
      white 9%,
      transparent 10%,
      transparent 12%,
      rgba(255, 255, 255, 0.3) 18%,
      transparent 20%,
      transparent 22%,
      rgba(255, 255, 255, 0.6) 25%,
      white 26%,
      rgba(255, 255, 255, 0.3) 27%,
      transparent 30%,
      transparent 33%,
      rgba(255, 255, 255, 0.3) 35%,
      transparent 42%,
      transparent 100%
    ) 0% 0%/ 150% 100% no-repeat;
  -webkit-background-clip: text;
  animation: shine 5s infinite linear;
}

@keyframes shine {
  0% {
    background-position: 50% 0;
  }
  100% {
    background-position: -190% 0;
  }
}
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
<main>
  <p>Magic</p>
</main>
1
2
3
main {
  width: 100%;
  height: 400px;
  display: grid;
  place-items: center;
  background: #000;
}

p {
  position: relative;
  font-size: 180px;
  overflow: hidden;
  -webkit-text-stroke: 3px #7272a5;
}

p::before {
  content: ' ';
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-image: linear-gradient(45deg, #ff269b, #2ab5f5, #ffbf00);
  mix-blend-mode: multiply;
}

p::after {
  content: ' ';
  position: absolute;
  top: -100%;
  left: -100%;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle, #fff, #000 50%) center/25% 25%;
  mix-blend-mode: color-dodge;
  animation: mix 8s linear infinite;
}

@keyframes mix {
  to {
    transform: translate(50%, 50%);
  }
}
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
以父之名
周杰伦.mp3