<!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">
<script src="./js/jquery-3.6.0.min.js"></script>
<title>垂直导航栏</title>
<style>
*{
margin: 0;
padding: 0;
}
.bar,.second li{
width: 100px;
height: 30px;
background-color: antiquewhite;
}
.bar:hover{
background-color: blueviolet;
}
.bar p{
text-align: center;
line-height: 30px;
}
.second{
display: none;
}
.second ul{
list-style: none;
}
.second li:hover{
background-color:wheat;
}
.second p{
text-align: center;
line-height: 30px;
}
</style>
</head>
<body>
<div class="bar" id="bar">
<p>菜单一</p>
</div>
<div class="second" id="second">
<ul>
<li id="one">
<p>1.1</p>
</li>
<li>
<p>1.2</p>
</li>
<li>
<p>1.3</p>
</li>
</ul>
</div>
<div class="bar" id="bar2">
<p>菜单二</p>
</div>
<div class="second" id="second2">
<ul>
<li id="one">
<p>2.1</p>
</li>
<li>
<p>2.2</p>
</li>
<li>
<p>2.3</p>
</li>
</ul>
</div>
<div class="bar" id="bar3">
<p>菜单三</p>
</div>
<div class="second" id="second3">
<ul>
<li id="one">
<p>3.1</p>
</li>
<li>
<p>3.2</p>
</li>
<li>
<p>3.3</p>
</li>
</ul>
</div>
<script>
$(document).ready(function(){
$("#bar").click(function(){
$("#second").slideToggle("slow");})
$("#bar2").click(function(){
$("#second2").slideToggle("slow");})
$("#bar3").click(function(){
$("#second3").slideToggle("slow");})
});
</script>
</body>
</html>
06-18