文字故障

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

<main>
  <section data-word="Magic">
    Magic
    <span></span>
  </section>
</main>
1
2
3
4
5
6
main {
  height: 400px;
  background: #000;
  position: relative;
}

section {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #fff;
  font-size: 72px;
  line-height: 72px;
}

section::before {
  content: attr(data-word);
  position: absolute;
  top: 0;
  left: 0.02em;
  height: 0;
  z-index: 2;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0.01em 0 0 red;
  filter: contrast(200%);
  animation: red-shadow 1s ease-in infinite;
}

section::after {
  content: attr(data-word);
  position: absolute;
  top: 0;
  left: -0.06em;
  height: 70%;
  z-index: 3;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.8);
  background: rgba(0, 0, 0, 0.9);
  text-shadow: -0.02em 0 0 cyan;
  filter: contrast(200%);
  mix-blend-mode: darken;
  animation: red-height 1.5s ease-out infinite;
}

span {
  position: absolute;
  left: 0;
  width: 100%;
  height: 7%;
  z-index: 4;
  background: #000;
  animation: white-move 3s ease-out infinite;
}

@keyframes red-shadow {
  20% {
    height: 90%;
  }
  60% {
    height: 10%;
  }
  100% {
    height: 120%;
  }
}

@keyframes red-height {
  20% {
    height: 120%;
  }
  35% {
    height: 30%;
  }
  50% {
    height: 110%;
  }
  60% {
    height: 50%;
  }
  70% {
    height: 90%;
  }
  80% {
    height: 60%;
  }
  100% {
    height: 0%;
  }
}

@keyframes white-move {
  8% {
    top: 110%;
  }
  14% {
    top: 20%;
  }
  20% {
    top: 120%;
  }
  32% {
    top: 5%;
  }
  99% {
    top: 80%;
  }
}
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
以父之名
周杰伦.mp3