-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fade-inAndFade-out.html
144 lines (126 loc) · 3.38 KB
/
Fade-inAndFade-out.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>淡入淡出实现</title>
<style>
body {
margin: 0;
font-family: sans-serif;
}
ul {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, 50%);
padding: 0;
margin: 0;
display: flex;
}
ul li {
list-style: none;
}
ul li a {
position: relative;
display: block;
padding: 10px 20px;
margin: 20px 0px;
text-decoration: none;
color: black;
font-weight: bold;
transition: 0.5s;
}
ul li a:before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-top: 1px solid black;
border-bottom: 1px solid black;
transform: scaleY(2);
opacity: 0;
transition: 0.5s;
}
ul li a:hover::before {
transform: scaleY(1);
opacity: 1;
}
ul li a:hover {
color: white;
}
ul li a:after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-top: 1px solid black;
border-bottom: 1px solid black;
transform: scaleY(2);
background-color: black;
opacity: 0;
transition: 0.5s;
z-index: -1;
}
ul li a:hover:after {
transform: scaleY(1);
opacity: 1;
}
#abutton {
position: absolute;
border: 3px solid black;
padding: 10px 15px;
top: 50%;
left: 45%;
text-decoration: none;
color: black;
font-weight: bold;
}
/* #abutton:hover {
background-color: black;
color: white;
} */
#abutton:hover {
color: white;
/* background-color: black;
opacity: 1;
transition: .5s */
}
#abutton:after {
background-color: black;
content: '';
top: 0;
left: 0;
position: absolute;
opacity: 0;
color: white;
z-index: -2;
width: 100%;
height: 100%;
transition: .5s;
}
#abutton:hover::after {
opacity: 1;
}
</style>
</head>
<body>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Index</a></li>
<li><a href="#">Home</a></li>
<li><a href="#">Home</a></li>
<li><a href="#">Index</a></li>
<li><a href="#">Home</a></li>
<li><a href="#">Home</a></li>
<li><a href="#">Index</a></li>
<li><a href="#">Home</a></li>
</ul>
<a id="abutton" href="#">淡入淡出的按钮</a>
</body>
</html>