开发者

;Jquery: animate page down 100px from current screen position

I need to animate a scroll from the curr开发者_如何学Cent screen position, down a set number of pixels.

    $('html,body').animate({
        scrollTop: $(window).position().top += 100
    });

or?

    $('html,body').animate({
        scrollTop: '+=100px'
    });


Just change:

scrollTop: $('body').position().top += 100

To this:

scrollTop: $(window).scrollTop() + 100

See demo: http://jsfiddle.net/fpxuC/


$('html,body').animate({
        scrollTop: $(window).position().top += 100
    })

$('html,body').animate({
        scrollTop: '+=100px'
    })

scrollTop: $('body').position().top += 100

scrollTop: $(window).scrollTop() + 100


Check out the jQuery.ScrollTo plugin. You can do something like: $(...).scrollTo( '+=100px', 800 );

Check out the sample for everything this plugin can do: http://demos.flesler.com/jquery/scrollTo/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜