0

目前,对于我的视差站点,我在每个部分都有下一个和上一个按钮。我只想拥有一组将转到每个部分的上一个/下一个导航。

你能告诉我下哪条路线吗?

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: $(document).ready(function() {

                    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但它没有点击进入下一部分

使用的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;
               });


        });

很抱歉,很长的帖子想提供尽可能多的信息

谢谢

4

1 回答 1

1

您没有在 href 下一页中插入锚标记,您需要为页面的每个部分添加它,然后通过单击它自动转到下一页或上一页..因为您只需插入 (#) 所以什么也没发生...

于 2013-09-16T05:42:39.013 回答