基于jQuery實現頁面定位導航滾動切換代碼



34 133 45



特效描述:基于jQuery實現 頁面定位導航 滾動切換,基于jQuery實現頁面定位導航滾動切換代碼

代碼結構

1. 引入CSS

<link href="css/zzsc.css" rel="stylesheet" media="all">

2. 引入JS

<script src="js/jquery.min.js"></script>
<script src="js/jquery.nav.js"></script>

3. HTML代碼

<ul id="nav">
  <li class="current"><a href="#examples">examples</a></li>
  <li><a href="#section-1">Section 1</a></li>
  <li><a href="#section-2">Section 2</a></li>
  <li><a href="#section-3">Section 3</a></li>
</ul>
<div id="container">
  <div class="section-wrapper" id="examples">
    <div class="section">
      <h2>Examples</h2>
      <p><a href="index2.html">垂直位置導航</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="index.html">水平位置導航</a></p>
    </div>
  </div>
  <div class="section-wrapper" id="section-1">
    <div class="section">
      <h1>Horizontal Nav</h1>
      <p>To account for the offset of the horizontal nav, add top negative margin and top padding. For example, the navigation on this page is 50px tall. So to each section, add a -50px top margin and 50px to offset the height of the nav. That means when you go to each section, it will scroll to the exact top of the section while accounting for the height of the nav.</p>
    </div>
  </div>
  <div class="section-wrapper" id="section-2">
    <div class="section">
      <h2>Section 2</h2>
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    </div>
  </div>
  <div class="section-wrapper" id="section-3">
    <div class="section">
      <h2>Section 3</h2>
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
    </div>
  </div>
</div>
<script>
$(function(){
	$('#nav').onePageNav();
});
</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下拉導航菜單 滑動導航菜單 滑動導航 滑動菜單 滾動導航菜單 滾動菜單 滾動導航 滑動選項卡 滑動切換 滾動切換 滾動條切換 自動滾動圖片輪播 選項卡切換 選項卡 切換 tab切換 頁面切換 選項卡插件 切換插件 滑動手風琴 導航菜單 導航條 菜單欄 導航欄 分類導航 響應式導航條 響應式導航 固定導航 固定菜單 全屏滾動 文字導航菜單 文字導航 文字菜單 全屏切換
×
×

注冊

官方QQ群

掃描上面二維碼加微信群

官方QQ群

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

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

老夫子电子