利用jQuery實現側邊浮動多級導航菜單代碼



23 91 31



特效描述:利用jQuery實現 側邊浮動 多級導航 菜單代碼,利用jQuery實現側邊浮動多級導航菜單代碼

代碼結構

1. 引入CSS

<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway:200,300,400,600,700">
<link rel="stylesheet" type="text/css" href="css/reset.css">
<link rel="stylesheet" href="css/demo.css">

2. 引入JS

<script src="js/jquery-1.11.0.min.js" type="text/javascript"></script>
<script type="text/javascript" src="dist/hc-mobile-nav.js"></script>

3. HTML代碼

<div id="container">
  <header>
	<div class="wrapper cf">
	  <nav id="main-nav">
		<ul class="first-nav">
		  <li class="cryptocurrency">
			<a href="#" target="_blank">Cryptocurrency</a>
			<ul>
			  <li><a href="#">Bitcoin</a></li>
			  <li><a href="#">Ethereum</a></li>
			  <li><a href="#">NEO</a></li>
			  <li><a href="#">ZCash</a></li>
			  <li><a href="#">Dogecoin</a></li>
			</ul>
		  </li>
		</ul>
		<ul class="second-nav">
		  <li class="devices">
			<a>Devices</a>
			<ul>
			  <li class="mobile">
				<a href="#">Mobile Phones</a>
				<ul>
				  <li><a href="#">Super Smart Phone</a></li>
				  <li><a href="#">Thin Magic Mobile</a></li>
				  <li><a href="#">Performance Crusher</a></li>
				  <li><a href="#">Futuristic Experience</a></li>
				</ul>
			  </li>
			  <li class="television">
				<a href="#">Televisions</a>
				<ul>
				  <li><a href="#">Flat Superscreen</a></li>
				  <li><a href="#">Gigantic LED</a></li>
				  <li><a href="#">Power Eater</a></li>
				  <li><a href="#">3D Experience</a></li>
				  <li><a href="#">Classic Comfort</a></li>
				</ul>
			  </li>
			  <li class="camera">
				<a href="#">Cameras</a>
				<ul>
				  <li><a href="#">Smart Shot</a></li>
				  <li><a href="#">Power Shooter</a></li>
				  <li><a href="#">Easy Photo Maker</a></li>
				  <li><a href="#">Super Pixel</a></li>
				</ul>
			  </li>
			</ul>
		  </li>
		  <li class="magazines">
			<a href="#">Magazines</a>
			<ul>
			  <li><a href="#">National Geographic</a></li>
			  <li><a href="#">Scientific American</a></li>
			  <li><a href="#">The Spectator</a></li>
			  <li><a href="#">The Rambler</a></li>
			  <li><a href="#">Physics World</a></li>
			  <li><a href="#">The New Scientist</a></li>
			</ul>
		  </li>
		  <li class="store">
			<a href="#">Store</a>
			<ul>
			  <li>
				<a href="#">Clothes</a>
				<ul>
				  <li>
					<a href="#">Women's Clothing</a>
					<ul>
					  <li><a href="#">Tops</a></li>
					  <li><a href="#">Dresses</a></li>
					  <li><a href="#">Trousers</a></li>
					  <li><a href="#">Shoes</a></li>
					  <li><a href="#">Sale</a></li>
					</ul>
				  </li>
				  <li>
					<a href="#">Men's Clothing</a>
					<ul>
					  <li><a href="#">Shirts</a></li>
					  <li><a href="#">Trousers</a></li>
					  <li><a href="#">Shoes</a></li>
					  <li><a href="#">Sale</a></li>
					</ul>
				  </li>
				</ul>
			  </li>
			  <li>
				<a href="#">Jewelry</a>
			  </li>
			  <li>
				<a href="#">Music</a>
			  </li>
			  <li>
				<a href="#">Grocery</a>
			  </li>
			</ul>
		  </li>
		  <li class="collections"><a href="#">Collections</a></li>
		  <li class="credits"><a href="#">Credits</a></li>
		</ul>
	  </nav>
	  <h1>HC MobileNav</h1>
	  <a class="toggle">
		<span></span>
		Toggle Navigation
	  </a>
	</div>
  </header>
  <main>
	<div class="wrapper">
	  <div class="content">
		<h4>Chose side</h4>
		<div class="actions">
		  <div><a href="#" data-demo="{side:'left'}" class="button active">Left side</a></div>
		  <div><a href="#" data-demo="{side:'right'}" class="button">Right side</a></div>
		</div>
		<h4>Levels open</h4>
		<div class="actions">
		  <div><a href="#" data-demo="{levelOpen:'overlap', levelSpacing:40}" class="button active">Overlap levels</a></div>
		  <div><a href="#" data-demo="{levelOpen:'expand', levelSpacing:25}" class="button">Expand levels</a></div>
		  <div><a href="#" data-demo="{levelOpen:false, levelSpacing:25}" class="button">Unfolded levels</a></div>
		</div>
	  </div>
	</div>
  </main>
</div>
<script>
	(function($) {
	  var $nav = $('#main-nav');
	  var $toggle = $('.toggle');
	  var defaultData = {
		maxWidth: false,
		customToggle: $toggle,
		navTitle: 'All Categories',
		levelTitles: true
	  };
	  // we'll store our temp stuff here
	  var $clone = null;
	  var data = {};
	  // calling like this only for demo purposes
	  const initNav = function(conf) {
		if ($clone) {
		  // clear previous instance
		  $clone.remove();
		}
		// remove old toggle click event
		$toggle.off('click');
		// make new copy
		$clone = $nav.clone();
		// remember data
		$.extend(data, conf)
		// call the plugin
		$clone.hcMobileNav($.extend({}, defaultData, data));
	  }
	  // run first demo
	  initNav({});
	  $('.actions').find('a').on('click', function(e) {
		e.preventDefault();
		var $this = $(this).addClass('active');
		var $siblings = $this.parent().siblings().children('a').removeClass('active');
		initNav(eval('(' + $this.data('demo') + ')'));
	  });
	})(jQuery);
</script>



用戶評論
大牛,別默默的看了,快登錄幫我點評一下吧!:)      登錄 | 注冊


熱門標簽: 滾動導航菜單 滾動菜單 滾動導航 滑動導航菜單 滑動導航 滑動菜單 浮動菜單 浮動導航 導航切換 菜單切換 右鍵菜單 收縮菜單 收縮導航 h5動畫導航 h5動畫菜單 html5動畫導航 html5動畫菜單 flash導航菜單 flash導航條 flash導航 flash菜單 flash下拉菜單 flash下拉導航菜單 收縮展開 展開收縮 收縮 展開 導航菜單 導航條 菜單欄 導航欄 分類導航 響應式導航條 響應式導航 收縮菜單 收縮導航 側邊菜單 側邊導航
?
×
×

注冊

官方QQ群

掃描上面二維碼加微信群

官方QQ群

jQuery/js討論群
群號:642649996
Css3+Html5討論群
群號:322131262

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

老夫子电子 3d字谜图谜总汇牛 福建体彩11选5开奖结果今天 今晚河南25选5开奖结果 南京麻将官方网 天津快乐十分直播 广西快乐双彩24选7走势图 快乐彩十二选五浙江 黑龙江22选5 01 04 06 09 出来过吗19 网上兼职赚钱app 快乐扑克牌3怎么玩法 永利皇宫app下载 体彩6 1中奖规则 十分十一选五开奖走势 福建22选7开奖结果 美国a片 明星 海南4+1开奖结果走势图