JS实现手风琴下拉菜单。
代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My手风琴菜单</title>
</head>
<body>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
body{
background: black;
}
#box{
margin: 50px auto;
background: white;
width: 200px;
height: auto;
border: 1px solid forestgreen;
}
ul{
list-style: none;
}
a{
text-align: center;
text-decoration: none;
display: block;
color: red;
}
span{
line-height: 40px;
}
.nav_title{
height: 40px;
text-align: center;
border-bottom: 1px solid grey;
cursor: pointer;
}
a:hover{
background-color: pink;
}
.nav_content li{
line-height: 40px;
border-bottom: 1px solid grey;
cursor: pointer;
}
.nav_content{
overflow: hidden;
background-color: rgba(0,0,0,0.7);
}
</style>
<div id="box">
<ul>
<li>
<div class="nav_title"><span class="span1">One</span></div>
<ul class="nav_content">
<li><a href="#">内容1</a> </li>
<li><a href="#">内容1</a> </li>
<li><a href="#">内容1</a> </li>
</ul>
</li>
<li>
<div class="nav_title"><span class="span1">Two</span></div>
<ul class="nav_content">
<li><a href="#">内容