jQuery實(shí)現(xiàn)二級導(dǎo)航菜單的示例
實(shí)用JQ實(shí)現(xiàn)導(dǎo)航二級菜單效果,導(dǎo)航菜單在網(wǎng)站中非常常見,有的網(wǎng)站可能會出現(xiàn)三級菜單及多級菜單模式,下面我們來簡單的實(shí)現(xiàn)一個二級菜單的效果。
部分效果截圖:

整體代碼:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>導(dǎo)航菜單案例</title>
<style>
*{
padding: 0;
margin: 0;
}
ul,li{
list-style: none;
}
a{
text-decoration: none;
}
nav{
width: 1140px;
height: 40px;
margin: 0 auto;
border:solid 1px #CCC;
position: relative;
}
nav ul li{
width: 150px;
line-height: 40px;
float: left;
}
nav ul li a{
display: block;
width: 100%;
float: left;
color: #444;
font-size: 14px;
text-align: center;
}
nav>ul>li:hover{
background: #f5f5f5;
}
nav ul li ul{
display: none;
width: 150px;
position: absolute;
background-color: #f5f5f5;
overflow: hidden;
top:41px;
}
nav ul li ul li{
float: left;
border-bottom: solid 1px #CCC;
}
nav ul li ul li:last-child{
border: none;
}
nav>ul>li>ul>li:hover a{
background-color: #444;
color: #FFF;
}
</style>
</head>
<body>
<br />
<br />
<nav>
<ul>
<li><a href="" title=" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 首頁">首頁</a></li>
<li><a href="" title=" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 聯(lián)系我們">聯(lián)系我們</a></li>
<li><a href="" title=" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 在線留言">在線留言</a></li>
<li>
<a href="" title=" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 新聞資訊">新聞資訊</a>
<ul>
<li><a href="" title=" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 國內(nèi)資訊">國內(nèi)資訊</a></li>
<li><a href="" title=" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 國內(nèi)資訊">國內(nèi)資訊</a></li>
</ul>
</li>
<li>
<a href="" title=" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 產(chǎn)品中心">產(chǎn)品中心</a>
<ul>
<li><a href="" title=" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 除雪機(jī)">除雪機(jī)</a></li>
<li><a href="" title=" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 運(yùn)雪車">運(yùn)雪車</a></li>
</ul>
</li>
<li><a href="" title=" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" 案例展示">案例展示</a></li>
</ul>
</nav>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script>
var $li = $("nav > ul > li");
$li.mouseenter(function () {
$(this).children("ul").stop().slideDown();
});
$li.mouseleave(function () {
$(this).children("ul").stop().slideUp();
});
</script>
</body>
</html>
以上就是jQuery實(shí)現(xiàn)二級導(dǎo)航菜單的示例的詳細(xì)內(nèi)容,更多關(guān)于jQuery實(shí)現(xiàn)二級導(dǎo)航菜單的資料請關(guān)注腳本之家其它相關(guān)文章!
- jQuery實(shí)現(xiàn)簡單漂亮的Nav導(dǎo)航菜單效果
- jQuery和CSS仿京東仿淘寶列表導(dǎo)航菜單
- 基于jQuery實(shí)現(xiàn)火焰燈效果導(dǎo)航菜單
- jQuery縱向?qū)Ш讲藛涡Ч麑?shí)現(xiàn)方法
- jQuery+CSS3實(shí)現(xiàn)仿花瓣網(wǎng)固定頂部位置帶懸浮效果的導(dǎo)航菜單
- jQuery+css實(shí)現(xiàn)非常漂亮的水平導(dǎo)航菜單效果
- jQuery模仿京東/天貓商品左側(cè)分類導(dǎo)航菜單效果
- 原生js和jquery分別實(shí)現(xiàn)橫向?qū)Ш讲藛涡Ч?/a>
- jQuery+CSS實(shí)現(xiàn)一個側(cè)滑導(dǎo)航菜單代碼
- jquery實(shí)現(xiàn)具有收縮功能的垂直導(dǎo)航菜單
- 基于jQuery實(shí)現(xiàn)以手風(fēng)琴方式展開和折疊導(dǎo)航菜單
相關(guān)文章
jquery實(shí)現(xiàn)從數(shù)組移除指定的值
這篇文章主要介紹了jquery實(shí)現(xiàn)從數(shù)組移除指定的值,涉及jQuery中g(shù)rep()方法對數(shù)組元素進(jìn)行過濾篩選的技巧,需要的朋友可以參考下2015-06-06
jQuery Validation實(shí)例代碼 讓驗(yàn)證變得如此容易
眾所周知,Jquery以其簡潔性讓無數(shù)人為之瘋狂?,F(xiàn)在我要像大家介紹一個jQuery Validation,一看到Validation大家肯定第一直觀感覺就是這肯定是一個驗(yàn)證框架,沒有錯,本文就是基于jQuery Validation展開討論。2010-10-10
jquery dataTable 獲取某行數(shù)據(jù)
本篇文章主要介紹了jquery dataTable 獲取某行數(shù)據(jù)的相關(guān)知識,具有很好的參考價(jià)值。下面跟著小編一起來看下吧2017-05-05
jquery ajax提交表單數(shù)據(jù)的兩種實(shí)現(xiàn)方法
貌似AJAX越來越火了,作為一個WEB程序開發(fā)者要是不會這個感覺就要落伍,甚至有可能在求職的時(shí)候?qū)冶惶蕴?。我也是一個WEB程序開發(fā)者,當(dāng)然我也要“隨波逐流”一把,不然飯碗不保啊!2010-04-04
ASP.NET jQuery 實(shí)例3 (在TextBox里面阻止復(fù)制、剪切和粘貼事件)
在這講里,讓我們看下如何在ASP.NET Textbox里禁止復(fù)制、剪切和粘貼行為2012-01-01
使用jquery.form.js實(shí)現(xiàn)圖片上傳的方法
這篇文章主要介紹了使用jquery.form.js實(shí)現(xiàn)圖片上傳的方法,涉及jquery使用表單插件jquery.form.js進(jìn)行圖片上傳的提交、類型驗(yàn)證、執(zhí)行結(jié)果回調(diào)顯示等技巧,非常簡單實(shí)用,需要的朋友可以參考下2016-05-05

