利用jQuery實現百度知道下拉導航菜單代碼



26 100 34



特效描述:利用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

加群請備注:從官網了解到

湖北30选5开奖结果走势图表