-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path多级菜单.html
97 lines (88 loc) · 2.14 KB
/
多级菜单.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>多级菜单</title>
<style>
* {
margin: 0;
padding: 0;
}
ol, ul {
list-style: none;
}
a {
text-decoration: none;
}
#main-menu .sub-menu {
float: left;
width: 100px;
height: 30px;
background-color: antiquewhite;
margin-right: 5px;
}
.sub-menu a {
width: 100%;
height: 100%;
display: block;
text-align: center;
line-height: 30px;
/*border-bottom: 1px dashed;*/
}
.sub-menu ul {
background-color: aqua;
display: none;
}
.sub-menu ul li {
border-bottom: 1px dashed #000;
}
#main-menu .sub-menu ul a {
text-align: left;
text-indent: 15px;
}
</style>
</head>
<body>
<ul id="main-menu">
<li class="sub-menu">
<a href="#">link1</a>
<ul>
<li><a href="#">sublink</a></li>
<li><a href="#">sublink</a></li>
<li><a href="#">sublink</a></li>
</ul>
</li>
<li class="sub-menu">
<a href="#">link2</a>
<ul>
<li><a href="#">sublink</a></li>
<li><a href="#">sublink</a></li>
<li><a href="#">sublink</a></li>
</ul>
</li>
<li class="sub-menu">
<a href="#">link3</a>
<ul>
<li><a href="#">sublink</a></li>
<li><a href="#">sublink</a></li>
<li><a href="#">sublink</a></li>
</ul>
</li>
</ul>
<script>
var oUl = document.getElementById("main-menu");
var aLi = oUl.children;
console.log(aLi);
for (var i = 0; i < aLi.length; i++) {
aLi[i].onmouseover = function () {
var oUl2 = this.children[1];
oUl2.style.display = "block";
};
aLi[i].onmouseout = function () {
var oUl2 = this.children[1];
oUl2.style.display = "none"
};
}
</script>
</body>
</html>