用jQuery实现网页卷轴的效果:http://www.56mp.cn/UPLOAD/SmoothPageScroll/
jQuery有能力做出这样的动画滚动,利用其动画功能和“ scrollTop ”参数。
最好的处理方法是在您的网页上设置滚动指标散列标记的链接(如 #about)。您设置的“href” 的锚链指向链接“#target”,然后链接会跳转到网页元素在该网页上的“target”作为其编号。这意味着它将不论已启用JavaScript或不启用都能动行。
以下是代码:
$(function(){
$('a[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) {
var targetOffset = $target.offset().top;
$('html,body').animate({scrollTop: targetOffset}, 1000);
return false;
}
}
});
});