jQuery:将页面从当前位置向下滚动100像素 [英] Jquery: scroll page down 100px from where it currently is

查看:1089
本文介绍了jQuery:将页面从当前位置向下滚动100像素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在距当前位置100像素以下的页面上设置动画?

How do I animate the page down 100px from where it currently is?

我的代码不起作用:

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

像这样,但没有它,则将页面滚动到特定元素,而是从Windows当前位置滚动100px:

like this, but without it scrolling the page to a specific element, instead, scrolling 100px from the windows current position:

$('html, body').animate({
scrollTop: $("#scrollToHere").offset().top
}, 2000);

推荐答案

想到了scrollto插件:
http://flesler.blogspot.com/2007/10/jqueryscrollto.html
http://demos.flesler.com/jquery/scrollTo/

The scrollto plugin comes to mind:
http://flesler.blogspot.com/2007/10/jqueryscrollto.html
http://demos.flesler.com/jquery/scrollTo/

但是这可能有点矫kill过正:)

but maybe it's a bit overkill for that :)

这篇关于jQuery:将页面从当前位置向下滚动100像素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆