利用jQuery实现百度知道下拉导航菜单代码



18 68 23



特效描述:利用jQuery实现 百度知道 下拉导航 菜单代码,利用jQuery实现百度知道下拉导航菜单代码

代码结构

1. 引入CSS

<link href="css/base.css" rel="stylesheet" type="text/css">
<link href="css/style.css" rel="stylesheet" type="text/css">

2. 引入JS

<script type="text/javascript" src="js/jquery.min.js"></script>

3. HTML代码

<section id="nav-content" class="nav-menu-content-box">
	<div class="nav-menu-content">
		<div class="nav-menu-content-item">
			<div class="nav-menu-content-cell">
				<div class="nav-menu-content-sell">
					<div class="nav-menu-content-list">
						<div class="nav-menu-content-home">
							<a href="#">首页</a>
						</div>
						<div class="nav-menu-content-info">
							<div class="navMenu-item navMenu-item-one">
								<a href="javascript:;" class="navMenu-title">问题</a>
								<div class="navMenu-item-content">
									<ul>
										<li>
											<a href="javascript:;">全部问题</a>
										</li>
										<li>
											<a href="javascript:;">经济金融</a>
										</li>
										<li>
											<a href="javascript:;">企业管理</a>
										</li>
										<li>
											<a href="javascript:;">法律法规</a>
										</li>
										<li>
											<a href="javascript:;">社会民生</a>
										</li>
										<li>
											<a href="javascript:;">科学教育</a>
										</li>
										<li>
											<a href="javascript:;">健康生活</a>
										</li>
										<li>
											<a href="javascript:;">体育运动</a>
										</li>
										<li>
											<a href="javascript:;">文艺演出</a>
										</li>
										<li>
											<a href="javascript:;">电子数码</a>
										</li>
										<li>
											<a href="javascript:;">电脑网络</a>
										</li>
										<li>
											<a href="javascript:;">娱乐休闲</a>
										</li>
									</ul>
								</div>
							</div>
							<div class="navMenu-item navMenu-item-two">
								<a href="javascript:;" class="navMenu-title">精选</a>
								<div class="navMenu-item-content">
									<ul>
										<li>
											<a href="javascript:;">知道专栏</a>
										</li>
										<li>
											<a href="javascript:;">知道数据</a>
										</li>
										<li>
											<a href="javascript:;">知道日报</a>
										</li>
										<li>
											<a href="javascript:;">知道信息</a>
										</li>
										<li>
											<a href="javascript:;">知道非遗</a>
										</li>
									</ul>
								</div>
							</div>
							<div class="navMenu-item navMenu-item-three">
								<a href="javascript:;" class="navMenu-title">
									用户 <div class="nav-icon">N</div>
								</a>
								<div class="navMenu-item-content">
									<ul>
										<li style="width:100%">
											<a href="javascript:;">知道合伙人(内测)</a>
										</li>
										<li>
											<a href="javascript:;">芝麻团</a>
										</li>
										<li>
											<a href="javascript:;">芝麻将</a>
										</li>
										<li>
											<a href="javascript:;">知道行家</a>
										</li>
										<li>
											<a href="javascript:;">日报作者</a>
										</li>
										<li>
											<a href="javascript:;">知道之星</a>
										</li>
										<div class="navMenu-list-title">
											机构合作
										<div class="navMenu-list-line"></div>
										</div>
										<li>
											<a href="javascript:;">机构行家</a>
										</li>
										<li>
											<a href="javascript:;">开放平台</a>
										</li>
										<li>
											<a href="javascript:;">品牌合作</a>
										</li>
										<div class="navMenu-list-title">
											知道福利
										<div class="navMenu-list-line"></div>
										</div>
										<li>
											<a href="javascript:;">财富商城</a>
										</li>
									</ul>
								</div>
							</div>
							<div class="navMenu-item navMenu-item-four">
								<a href="javascript:;" class="navMenu-title">特色</a>
								<div class="navMenu-item-content">
									<ul>
										<li>
											<a href="javascript:;">
												<span class="navMenu-item-img">
													<img src="img/a1.png" alt="">
												</span>
												<span class="navMenu-item-tex">经验</span>
											</a>
										</li>
										<li>
											<a href="javascript:;">
												<span class="navMenu-item-img">
													<img src="img/b1.png" alt="">
												</span>
												<span class="navMenu-item-tex">宝宝知道</span>
											</a>
										</li>
										<li>
											<a href="javascript:;">
												<span class="navMenu-item-img">
													<img src="img/c1.png" alt="">
												</span>
												<span class="navMenu-item-tex">作业帮</span>
											</a>
										</li>
									</ul>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</section>
<script type="text/javascript">
	$(document).ready(function(){
		$('.nav-menu-content-box').hover(function() {
			$(this).addClass('dow-hover');
			$(".nav-menu-content").show('slow');
		}, function() {
			$(this).removeClass('dow-hover');
		});
	});
	var maxHeight = 400;
	$(function(){
		$(".nav-menu-content-box > li").hover(function() {
			var $container = $(this),
				$list = $container.find("ul"),
				$anchor = $container.find("a"),
				height = $list.height() * 1.1,
				multiplier = height / maxHeight;
			$container.data("origHeight", $container.height());
			$anchor.addClass("hover");
			$list
				.show()
				.css({
					paddingTop: $container.data("origHeight")
				});
			if (multiplier > 1) {
				$container
					.css({
						height: maxHeight,
						overflow: "hidden"
					})
					.mousemove(function(e) {
						var offset = $container.offset();
						var relativeY = ((e.pageY - offset.top) * multiplier) - ($container.data("origHeight") * multiplier);
						if (relativeY > $container.data("origHeight")) {
							$list.css("top", -relativeY + $container.data("origHeight"));
						};
					});
			}
		}, function() {
			var $el = $(this);
			$el
				.height($(this).data("origHeight"))
				.find("ul")
				.css({ top: 0 })
				.hide()
				.end()
				.find("a")
				.removeClass("hover");
		});
	});
</script>
<div style="text-align:center;margin:50px 0; font:normal 14px/24px 'MicroSoft YaHei';">
</div>



用户评论
大牛,别默默的看了,快登录帮我点评一下吧!:)      登录 | 注册


热门标签: 滚动导航菜单 滚动菜单 滚动导航 滑动导航菜单 滑动导航 滑动菜单 浮动菜单 浮动导航 导航切换 菜单切换 右键菜单 收缩菜单 收缩导航 h5动画导航 h5动画菜单 html5动画导航 html5动画菜单 flash导航菜单 flash导航条 flash导航 flash菜单 flash下拉菜单 flash下拉导航菜单 收缩展开 展开收缩 收缩 展开 导航菜单 导航条 菜单栏 导航栏 分类导航 响应式导航条 响应式导航 收缩菜单 收缩导航 下拉列表 下拉菜单 下拉导航 下拉导航菜单 下拉菜单导航 响应式下拉菜单

×
×

注册

官方QQ群

扫描上面二维码加微信群

官方QQ群

jQuery/js讨论群
群号:642649996
Css3+Html5讨论群
群号:322131262

加群请备注:从官网了解到