# 纯CSS3实现2个的鼠标悬停文本下划线动画效果
# 快速导航
# 示例效果
"网名:随笔川迹,别名"川川",微信同号(suibichuanji),用笔尖下的文字随性而写. 不拘泥于技术,希望能在岁月的侵蚀中留下自己一点足迹,让成长有迹可寻,努力成为一个有故事的人
# 示例代码
示例代码
<template>
<div>
<div>
<p>
"网名:随笔川迹,别名"川川",<a class="link-1" href="#">微信同号(suibichuanji)</a>,用笔尖下的文字随性而写. 不拘泥于技术,希望能在岁月的侵蚀中留下自己一点足迹,让<a class="link-2">成长有迹可寻</a>,努力成为一个有故事的人
</p>
</div>
</div>
</template>
<style>
a {
cursor: pointer;
}
strong {
margin-top: 16px;
display: block;
font-weight: 700;
}
p {
padding: 24px;
max-width: 760px;
font-size: 22px;
font-weight: 300;
line-height: 1.9;
}
.link-1 {
position: relative;
text-decoration: none;
display: inline-block;
color: black;
padding: 0 1px;
-webkit-transition: color ease 0.3s;
transition: color ease 0.3s;
}
.link-1::after {
content: '';
position: absolute;
z-index: -1;
width: 100%;
height: 5%;
left: 0;
bottom: 0;
background-color: #00B388;
-webkit-transition: all ease 0.3s;
transition: all ease 0.3s;
}
.link-1:hover {
color: white;
}
.link-1:hover::after {
height: 100%;
}
.link-2 {
position: relative;
text-decoration: none;
display: inline-block;
color: black;
padding: 0 1px;
-webkit-transition: color ease 0.3s;
transition: color ease 0.3s;
}
.link-2::before,
.link-2::after {
content: '';
position: absolute;
background-color: #00B388;
z-index: -1;
height: 5%;
}
.link-2::before {
width: 0%;
left: 0;
bottom: 0;
-webkit-transition: width ease 0.4s;
transition: width ease 0.4s;
}
.link-2::after {
width: 100%;
left: 0;
bottom: 0;
-webkit-transition: all ease 0.6s;
transition: all ease 0.6s;
}
.link-2:hover::before {
width: 100%;
}
.link-2:hover::after {
left: 100%;
width: 0%;
-webkit-transition: all ease 0.2s;
transition: all ease 0.2s;
}
</style>
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
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