<!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>Document</title>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<style>
* {
padding: 0px;
margin: 0px;
list-style: none;
}
.nav>li {
float: left;
margin: 0 30px 0 30px;
width: 70px;
text-align: center;
height: 30px;
line-height: 30px;
}
.nav_con li:first-child {
border-bottom: none;
border-top: none;
}
.nav_con li:last-child {
border-top:none;
}
.nav_con li {
border: 1px solid #ffe2b0;
}
.nav_con{
display: none;
}
.nav>li:hover{
background-color: pink;
}
</style>
</head>
<body>
<ul class="nav">
<li>
<a>微博</a>
<ul class="nav_con">
<li>消息</li>
<li>私信</li>
<li>@我</li>
</ul>
</li>
<li>
<a>微博</a>
<ul class="nav_con">
<li>消息</li>
<li>私信</li>
<li>@我</li>
</ul>
</li>
<li>
<a>微博</a>
<ul class="nav_con">
<li>消息</li>
<li>私信</li>
<li>@我</li>
</ul>
</li>
</ul>
</body>
<script>
$(function(){
$(".nav>li").mouseover(function(){
$(this).children("ul").show()
})
$(".nav>li").mouseout(function(){
$(this).children("ul").hide()
})
})
</script>
</html>
jQuery实现下拉菜单
最新推荐文章于 2024-05-17 13:52:13 发布