2013-08-21 34 views
0

目前我的視差網站我有每個部分上的下一個和上一個按鈕。我想只有一組prev/next導航將會到每個部分。視差下一個和上一個導航

你能告訴我關於下降的路線嗎?

HTML:

<head> 
    <title>The history of aeronautics</title> 

    <meta charset="utf-8" /> 
    <meta name="description" content="A parallax scrolling experiment using jQuery" /> 

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

    <script src="js/modernizr.custom.37797.js"></script> 
    <!-- Grab Google CDN's jQuery. fall back to local if necessary --> 
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script> 
    <script>!window.jQuery && document.write('<script src="/js/jquery-1.6.1.min.js"><\/script>')</script> 
    <script src="js/parallax.js"></script> 
</head> 

<body> 

    <div id="wrapper"> 

     <div id="car"><img src="images/car.png"></div> 

     <nav id="primary"> 
      <ul> 
       <li> 
        <h1>Hospital</h1> 
        <a class="hospital" href="#hospital">View</a> 
       </li> 
       <li> 
        <h1>University</h1> 
        <a class="university" href="#university">View</a> 
       </li> 
       <li> 
        <h1>Health Centre</h1> 
        <a class="health-centre" href="#health-centre">View</a> 
       </li> 
       <li> 
        <h1>Horiba HQ</h1> 
        <a class="horiba-hq" href="#horiba-hq">View</a> 
       </li> 
       <li> 
        <h1>Entertainment Hub</h1> 
        <a class="entertainment-hub" href="#entertainment-hub">View</a> 
       </li> 
       <li> 
        <h1>Vet</h1> 
        <a class="vet" href="#vet">View</a> 
       </li> 
       <li> 
        <h1>General Hospital</h1> 
        <a class="general-hospital" href="#general-hospital">View</a> 
       </li> 
      </ul> 
     </nav> 

     <div id="content"> 
      <article id="hospital"> 
      <a href="#"><img src="images/image1.png"/></a> 
       <ul class="ch-grid"> 
       <li> 
        <div class="ch-item ch-img-2"> 
         <div class="ch-info"> 
          <h3><a class="university" href="#university">Next</a></h3> 
         </div> 
        </div> 
       </li> 
       </ul> 
      </article> 

      <article id="university"> 
      <a href="#"><img src="images/image2.png"/></a> 
       <ul class="ch-grid"> 
       <li> 
        <div class="ch-item ch-img-1"> 
         <div class="ch-info"> 
          <h3><a class="hospital" href="#hospital">Prev</a></h3> 
         </div> 
        </div> 
       </li> 
       <li> 
        <div class="ch-item ch-img-2"> 
         <div class="ch-info"> 
          <h3><a class="health-centre" href="#health-centre">Next</a></h3> 
         </div> 
        </div> 
       </li> 
       </ul> 
      </article> 

      <article id="health-centre"> 
      <a href="#"><img src="images/image3.png"/></a> 
       <ul class="ch-grid"> 
       <li> 
        <div class="ch-item ch-img-1"> 
         <div class="ch-info"> 
          <h3><a class="university" href="#university">Prev</a></h3> 
         </div> 
        </div> 
       </li> 
       <li> 
        <div class="ch-item ch-img-2"> 
         <div class="ch-info"> 
          <h3><a class="horiba-hq" href="#horiba-hq">Next</a></h3> 
         </div> 
        </div> 
       </li> 
       </ul> 
      </article> 

      <article id="horiba-hq"> 
      <a href="#"><img src="images/image4.png"/></a> 
       <ul class="ch-grid"> 
       <li> 
        <div class="ch-item ch-img-1"> 
         <div class="ch-info"> 
          <h3><a class="health-centre" href="#health-centre">Prev</a></h3> 
         </div> 
        </div> 
       </li> 
       <li> 
        <div class="ch-item ch-img-2"> 
         <div class="ch-info"> 
          <h3><a class="entertainment-hub" href="#entertainment-hub">Next</a></h3> 
         </div> 
        </div> 
       </li> 
       </ul> 
      </article> 
      <article id="entertainment-hub"> 
      <a href="#"><img src="images/image5.png" /></a> 
       <ul class="ch-grid"> 
       <li> 
        <div class="ch-item ch-img-1"> 
         <div class="ch-info"> 
          <h3><a class="horiba-hq" href="#horiba-hq">Prev</a></h3> 
         </div> 
        </div> 
       </li> 
       <li> 
        <div class="ch-item ch-img-2"> 
         <div class="ch-info"> 
          <h3><a class="vet" href="#vet">Next</a></h3> 
         </div> 
        </div> 
       </li> 
       </ul> 
      </article> 
      <article id="vet"> 
      <a href="#"><img src="images/image6.png"/></a> 
       <ul class="ch-grid"> 
       <li> 
        <div class="ch-item ch-img-1"> 
         <div class="ch-info"> 
          <h3><a class="entertainment-hub" href="#entertainment-hub">Prev</a></h3> 
         </div> 
        </div> 
       </li> 
       <li> 
        <div class="ch-item ch-img-2"> 
         <div class="ch-info"> 
          <h3><a class="general-hospital" href="#general-hospital">Next</a></h3> 
         </div> 
        </div> 
       </li> 
       </ul> 
      </article> 
      <article id="general-hospital"> 
      <a href="#"><img src="images/hospital.png"/></a> 
       <ul class="ch-grid"> 
       <li> 
        <div class="ch-item ch-img-1"> 
         <div class="ch-info"> 
          <h3><a class="vet" href="#vet">Prev</a></h3> 
         </div> 
        </div> 
       </li> 
       </ul> 
      </article> 
     </div> 

     <!-- Parallax foreground --> 
     <div id="parallax-bg3"> 

     </div> 

     <!-- Parallax midground clouds --> 
     <div id="parallax-bg2"> 
      <img id="bg2-1" src="images/blurred-buildings.png" /> 

     </div> 

     <!-- Parallax background clouds --> 
     <div id="parallax-bg1"> 
      <img id="bg1-1" src="images/clouds.png" /> 

     </div> 

    </div> 

</body> 

JS: $(文件)。就緒(函數(){

    redrawDotNav(); 

        /* Scroll event handler */ 
        $(window).bind('scroll',function(e){ 
         parallaxScroll(); 
         redrawDotNav(); 
        }); 

        /* Next/prev and primary nav btn click handlers */ 
        $('a.hospital').click(function(){ 
         $('html, body').animate({ 
          scrollTop:0 
         }, 1000, function() { 
          parallaxScroll(); // Callback is required for iOS 
         }); 
        }); 
        $('a.university').click(function(){ 
         $('html, body').animate({ 
          scrollTop:1500 
         }, 1000, function() { 
          parallaxScroll(); // Callback is required for iOS 
         }); 
        }); 
        $('a.health-centre').click(function(){ 
         $('html, body').animate({ 
          scrollTop:3800 
         }, 1000, function() { 
          parallaxScroll(); // Callback is required for iOS 
         }); 
         return false; 
        }); 
        $('a.horiba-hq').click(function(){ 
         $('html, body').animate({ 
          scrollTop:5500 
         }, 1000, function() { 
          parallaxScroll(); // Callback is required for iOS 
         }); 
        }); 


        $('a.entertainment-hub').click(function(){ 
         $('html, body').animate({ 
          scrollTop:6800 
         }, 1000, function() { 
          parallaxScroll(); // Callback is required for iOS 
         }); 
        }); 
        $('a.vet').click(function(){ 
         $('html, body').animate({ 
          scrollTop:7700 
         }, 1000, function() { 
          parallaxScroll(); // Callback is required for iOS 
         }); 
        }); 
        $('a.general-hospital').click(function(){ 
         $('html, body').animate({ 
          scrollTop:11000 
         }, 1000, function() { 
          parallaxScroll(); // Callback is required for iOS 
         }); 
        }); 





        /* Show/hide dot lav labels on hover */ 
        $('nav#primary a').hover(
         function() { 
          $(this).prev('h1').show(); 
         }, 
         function() { 
          $(this).prev('h1').hide(); 
         } 
        ); 

       }); 

       /* Scroll the background layers */ 
       function parallaxScroll(){ 
        var scrolled = $(window).scrollTop(); 
        $('#content').css('left',(0-(scrolled*.9))+'px'); 
        $('#parallax-bg1').css('left',(0-(scrolled*.25))+'px'); 
        $('#parallax-bg2').css('left',(0-(scrolled*.5))+'px'); 
        $('#parallax-bg3').css('left',(0-(scrolled*.9))+'px'); 
       } 

       /* Set navigation dots to an active state as the user scrolls */ 
       function redrawDotNav(){ 
        var section1Top = 0; 
        // The top of each section is offset by half the distance to the previous section. 
        var section2Top = $('#university').offset().left + 1000; 
        var section3Top = $('#health-centre').offset().left +3000; 
        var section4Top = $('#horiba-hq').offset().left +4000; 
        var section5Top = $('#entertainment-hub').offset().left +6000; 
        var section6Top = $('#vet').offset().left +6800; 
        var section7Top = $('#general-hospital').offset().left +9100; 

        $('nav#primary a').removeClass('active'); 
        if($(document).scrollTop() >= section1Top && $(document).scrollTop() < section2Top){ 
         $('nav#primary a.hospital').addClass('active'); 
        } else if ($(document).scrollTop() >= section2Top && $(document).scrollTop() < section3Top){ 
         $('nav#primary a.university').addClass('active'); 
        } else if ($(document).scrollTop() >= section3Top && $(document).scrollTop() < section4Top){ 
         $('nav#primary a.health-centre').addClass('active'); 
        } else if ($(document).scrollTop() >= section4Top && $(document).scrollTop() < section5Top){ 
         $('nav#primary a.horiba-hq').addClass('active'); 
        } else if ($(document).scrollTop() >= section5Top && $(document).scrollTop() < section6Top){ 
         $('nav#primary a.entertainment-hub').addClass('active'); 
        } else if ($(document).scrollTop() >= section6Top && $(document).scrollTop() < section7Top){ 
         $('nav#primary a.vet').addClass('active'); 


        } else if ($(document).scrollTop() >= section7Top){ 
         $('nav#primary a.general-hospital').addClass('active'); 
        } 

       } 

我曾嘗試加入這個裏面可以被看到here但它does not點擊進入下一節

JS使用:

$(function() { 

      var $tabs = $('#content').tabs(); 

      $(".ui-tabs-panel").each(function(i){ 

       var totalSize = $(".ui-tabs-panel").size() - 1; 

       if (i != totalSize) { 
        next = i + 2; 
        $(this).append("<a href='#' class='next-tab mover' rel='" + next + "'>Next Page &#187;</a>"); 
       } 

       if (i != 0) { 
        prev = i; 
        $(this).append("<a href='#' class='prev-tab mover' rel='" + prev + "'>&#171; Prev Page</a>"); 
       } 

      }); 

      $('.next-tab, .prev-tab').click(function() { 
        $tabs.tabs('select', $(this).attr("rel")); 
        return false; 
       }); 


     }); 

抱歉長後想給儘可能多的信息儘可能

感謝

+0

我所做的是在這裏[鏈接](http://horiba.creativebridgedigital.com/test2.html) 我用上面的代碼使用js: – user2682105

回答

1

你沒有在HREF插入錨標記下一頁,你需要爲頁面的每一部分添加它,然後通過點擊該按鈕自動進入下一頁或上一頁。因爲你只需插入(#),這就是爲什麼什麼都沒有發生......

+0

不要忘記添加所有部分,即使是下一個和以前的頁面,你已經有錨點,如汽車,小學,內容,視差-bg3,視差-bg2,視差-bg1 .. :-) – Amin

+0

我忘了說,你也可以使用錨點在你的頁面,如果你添加這些名字,結果將是相同的,我的意思是醫院,大學,保健和.... – Amin

相關問題