# 常见的文字效果
背景知识
text-shadow (opens new window), filter (opens new window), -webkit-text-fill-color (opens new window), -webkit-text-stroke (opens new window)
<style scoped>
.main {
width: 100%;
font: 180%/1.5 Baskerville, Palatino, serif;
}
.main > div {
display: flex;
justify-content: space-around;
align-items: center;
flex-wrap: wrap;
}
.main > div > h5 {
width: 229px;
}
.main > div > p {
padding: 18px 28px;
text-align: justify;
hyphens: auto;
}
.main > div:nth-of-type(1) > p {
background: hsl(40, 28.57% , 58.82%);
color: hsl(40, 28.57% , 28.82%);
text-shadow: 0 .03em .03em hsla(0,0%,100%,.8);
}
.main > div:nth-of-type(2) > p {
background: hsl(40, 28.57% , 28.82%);
color: hsl(40, 28.57% , 58.82%);
text-shadow: 0 .03em .03em black;
}
.main > div:nth-of-type(3) > p {
background: #b4a078;
color: white;
/*text-shadow: 1px 1px black, -1px -1px black, 1px -1px black, -1px 1px black;*/
text-shadow: 0 0 2px hsl(40, 28.57% , 28.82%),
0 0 2px hsl(40, 28.57% , 28.82%),
0 0 2px hsl(40, 28.57% , 28.82%),
0 0 2px hsl(40, 28.57% , 28.82%),
0 0 2px hsl(40, 28.57% , 28.82%),
0 0 2px hsl(40, 28.57% , 28.82%),
0 0 2px hsl(40, 28.57% , 28.82%),
0 0 2px hsl(40, 28.57% , 28.82%),
0 0 2px hsl(40, 28.57% , 28.82%);
}
.main > div:nth-of-type(4) > p {
background: #b4a078;
color: white;
}
.main > div:nth-of-type(4) > p text{
fill: currentColor;
}
.main > div:nth-of-type(4) > p svg{
overflow: visible;
}
.main > div:nth-of-type(4) > p use{
stroke: hsl(40, 28.57% , 28.82%);
stroke-width: 3;
stroke-linejoin: round;
}
.main > div:nth-of-type(5) > p,
.main > div:nth-of-type(6) > p,
.main > div:nth-of-type(7) > p {
background: hsl(40, 28.57% , 28.82%);
}
.main > div:nth-of-type(5) > p a,
.main > div:nth-of-type(6) > p a,
.main > div:nth-of-type(7) > p a {
background: hsl(40, 28.57% , 28.82%);
color: white;
transition: .5s;
font-weight: 500;
text-shadow: 0 0 .1em, 0 0 .3em;
}
.main > div:nth-of-type(5) > p a:hover{
animation: .8s text-blink-effect infinite alternate;
}
.main > div:nth-of-type(6) > p a:hover{
color: transparent;
text-shadow: 0 0 .1em white, 0 0 .3em white;
}
.main > div:nth-of-type(7) > p a:hover{
filter: blur(2px);
}
.main > div:nth-of-type(8) > p {
background: #b4a078;
color: white;
text-shadow: 0 1px hsl(0, 0%, 90%),
0 1px hsl(0, 0%, 90%),
0 2px 4px hsla(0, 0%, 0%,.5);
}
.main > div:nth-of-type(9) > p {
background: #b4a078;
color: white;
text-shadow: 1px 1px hsl(40, 28.57% , 28.82%), 2px 2px hsl(40, 28.57% , 28.82%),
3px 3px hsl(40, 28.57% , 28.82%), 4px 4px hsl(40, 28.57% , 28.82%);
}
.main > div:nth-of-type(10) > p {
background: linear-gradient(90deg, #b4a078, #333);
-webkit-text-fill-color: white;
-webkit-background-clip: text;
-webkit-text-stroke: 5px transparent;
}
@keyframes text-blink-effect {
50% {
text-shadow: 0 0 .1em, 0 0 .3em;
}
to {
text-shadow: 0 0 .1em;
}
}
</style>
<template>
<div class="main">
<div>
<h5>1、浅色底深色字</h5>
<p>text-effect 文字特效</p>
</div>
<div>
<h5>2、深色底浅色字</h5>
<p>text-effect 文字特效</p>
</div>
<div>
<h5>3、空心字:text-shadow</h5>
<p>text-effect 文字特效</p>
</div>
<div>
<h5>4、空心字-SVG</h5>
<p>
<svg width="300px" height="1em">
<use xlink:href="#css" />
<text id="css" y="1em">text-effect 文字特效</text>
</svg>
</p>
</div>
<div>
<h5>5、外发光文字:text-shadow</h5>
<p><a>text-effect 文字特效</a></p>
</div>
<div>
<h5>6、模糊文字:text-shadow</h5>
<p><a>text-effect 文字特效</a></p>
</div>
<div>
<h5>7、模糊文字:filter</h5>
<p><a>text-effect 文字特效</a></p>
</div>
<div>
<h5>8、文字凸起</h5>
<p>text-effect 文字特效</p>
</div>
<div>
<h5>9、文字凸起</h5>
<p>text-effect 文字特效</p>
</div>
<div>
<h5>10、文字渐变</h5>
<p>text-effect 文字特效</p>
</div>
</div>
</template>
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
1、浅色底深色字
text-effect 文字特效
2、深色底浅色字
text-effect 文字特效
3、空心字:text-shadow
text-effect 文字特效
4、空心字-SVG
5、外发光文字:text-shadow
6、模糊文字:text-shadow
7、模糊文字:filter
8、文字凸起
text-effect 文字特效
9、文字凸起
text-effect 文字特效
10、文字渐变
text-effect 文字特效
通过text-shadow实现的模糊效果无法平稳退化~