2014-01-29 62 views
2

請查看此頁面(例子)滾動和平滑滾動碼

http://www.christinamichael.in/create-a-powerful-human-disintegration-effect-in-photoshop 

我想知道我怎麼能有這樣的這樣?

我想在Firefox和Chrome中支持一些東西。

+1

哇,這真的很煩人。我不會建議你這樣做。我的Chrome似乎有一些問題(滾動口吃)。 – Halcyon

+0

@FritsvanCampen真的嗎? : - ?謝謝你的評論 – user3248595

回答

1

您可以使用ANCHOR標籤進行平滑滾動。 以下結果。

$(function() { 
$('a[href*=#]:not([href=#])').click(function() { 
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { 
    var target = $(this.hash); 
    target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); 
    if (target.length) { 
    $('html,body').animate({ 
     scrollTop: target.offset().top 
    }, 1000); 
    return false; 
    } 
} 
    }); 
});