Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
140 lines (124 loc) · 3.78 KB
/
Copy pathindex.html
File metadata and controls
140 lines (124 loc) · 3.78 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>小亚の扩列站</title>
<style>
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: url(./bg.jpg) no-repeat center center fixed;
background-size: cover;
}
#nav {
position: relative;
border: none;
border-radius: 10em;
display: flex;
list-style: none;
background: #f5f5f5;
box-shadow: 20px 40px 40px #00000033;
padding: 10px;
}
#nav li a {
position: relative;
padding: 15px 50px;
font: 500 24px '优设标题黑';
border: none;
outline: none;
color: rgb(70, 100, 180);
display: inline-block;
text-decoration: none;
z-index: 3;
}
.slide1,
.slide2 {
position: absolute;
display: inline-block;
height: 60px;
border-radius: 10em;
transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1.05);
}
.slide1 {
background-color: rgb(170, 190, 255);
z-index: 2;
}
.slide2 {
opacity: 0;
background-color: rgba(170, 190, 255, .5);
z-index: 1;
box-shadow: 0 0 20px #ffffffaa inset;
}
.squeeze {
transform: scale(0.9);
}
/* 响应式调整 */
@media (max-width: 768px) {
body {
background-size: cover;
background-position: center;
}
#nav {
flex-direction: column;
align-items: center;
padding: 20px;
border-radius: 2em;
}
#nav li a {
padding: 10px 20px;
font-size: 18px;
}
.slide1, .slide2 {
height: 50px;
}
}
@media (max-width: 480px) {
#nav li a {
padding: 10px 15px;
font-size: 16px;
}
.slide1, .slide2 {
height: 45px;
}
}
</style>
</head>
<body>
<ul id="nav">
<li class="slide1"></li>
<li class="slide2"></li>
<li><a href="#">主页</a></li>
<li><a href="loading.html">关于小亚</a></li>
<li><a href="#">我要投稿</a></li>
<li><a href="#">联系站长</a></li>
<li><a href="#">留言板</a></li>
</ul>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$("#nav a").on("click", function () {
var position = $(this).parent().position();
var width = $(this).parent().width();
$("#nav .slide1").css({ opacity: 1, left: +position.left, width: width });
});
$("#nav a").on("mouseover", function () {
var position = $(this).parent().position();
var width = $(this).parent().width();
$("#nav .slide2").css({ opacity: 1, left: +position.left, width: width }).addClass("squeeze");
});
$("#nav a").on("mouseout", function () {
$("#nav .slide2").css({ opacity: 0 }).removeClass("squeeze");
});
var currentWidth = $("#nav li:nth-of-type(3) a").parent("li").width();
var current = $("li:nth-of-type(3) a").position();
$("#nav .slide1").css({ left: +current.left, width: currentWidth });
</script>
</html>