网络编程 
首页 > 网络编程 > 浏览文章

jQuery实现二级导航菜单的示例

(编辑:jimmy 日期: 2024/11/7 浏览:3 次 )

实用JQ实现导航二级菜单效果,导航菜单在网站中非常常见,有的网站可能会出现三级菜单及多级菜单模式,下面我们来简单的实现一个二级菜单的效果。

部分效果截图:

jQuery实现二级导航菜单的示例

整体代码:

<!DOCTYPE html>  
<html>  
	<head>  
		<meta charset="UTF-8">  
		<title>导航菜单案例</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" 联系我们">联系我们</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" 国内资讯">国内资讯</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>  
					</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>  
					<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" 运雪车">运雪车</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="/UploadFiles/2021-04-02/jquery-3.4.1.min.js">

以上就是jQuery实现二级导航菜单的示例的详细内容,更多关于jQuery实现二级导航菜单的资料请关注其它相关文章!

上一篇:在Vue里如何把网页的数据导出到Excel的方法
下一篇:javascript canvas封装动态时钟
高通与谷歌联手!首款骁龙PC优化Chrome浏览器发布
高通和谷歌日前宣布,推出首次面向搭载骁龙的Windows PC的优化版Chrome浏览器。
在对骁龙X Elite参考设计的初步测试中,全新的Chrome浏览器在Speedometer 2.1基准测试中实现了显著的性能提升。
预计在2024年年中之前,搭载骁龙X Elite计算平台的PC将面世。该浏览器的提前问世,有助于骁龙PC问世就获得满血表现。
谷歌高级副总裁Hiroshi Lockheimer表示,此次与高通的合作将有助于确保Chrome用户在当前ARM兼容的PC上获得最佳的浏览体验。