2014-11-01 45 views
-2

我需要幫助。我在一個項目中爲我的新網站工作,它有1頁可滾動圖像,一個視差網站。問題是當我點擊鏈接像關於專輯,聯繫人,等等...沒關係,頁面轉到about部分或聯繫人部分,但是立即,而不是scroll。我嘗試了不同的JQuery插件,例如scrollTo.js,stellar.js,但是id沒有起作用。可以幫忙我傢伙?我把包含index.html,style.css以及腳本和圖像的文件夾放在這裏:https://www.mediafire.com/folder/qne9srlc76xxa/Parallax_website頁面滾動不起作用

請看看代碼並給我一個解決方案。我只想知道我該怎麼去一個部分,一個div,當我點擊滾動鏈接菜單,現在直接。

謝謝你們。

希望你能幫助我!

+1

很少會下載一個主人MediaFire和測試,不建議使用的jsfiddle代替 – 2014-11-01 14:08:37

回答

1

我通常使用jquery此:

//animates the body to scroll to a section from the menu 

//selects links that have a hash tag 
$(".nav li a[href*='#']").on('click', function(e) { 

    //prevent the default action when an anchor link is clicked 
    e.preventDefault(); 

    //animate scrolling and go to that certain section pointed by the anchor link 
    $('html, body').animate({ scrollTop: $(this.hash).offset().top }, 600); 
});