Javascript / css:使用按钮垂直滚动页面
我实际上有一个具有静态高度和 100% 宽度的 div。目前这个 div 有 overflow:auto
所以有一个垂直滚动条。
但对于这个项目来说,这个 div 必须没有任何滚动条。所以我有两个按钮 - 一个位于 div 的顶部,一个位于末尾用于滚动。但到目前为止,我无法找到使用此按钮使 div 滚动(几个像素或鼠标悬停时滚动)的解决方案。
(我通常使用 jQuery,但无法使用它的 scrollTop()
-Method)
所以请帮助我!
I actually have a div with a staticheight and 100% width. Currently this div has overflow:auto
so there is a vertical scrollbar.
But for this project it's necessary to have this div without any scrollbars. So I have two buttons - one at the div's top and one at the end for scrolling. But until now I was unable to find a solution to make the div scrolling (for several px OR scrolling while mouseover) using this buttons.
(I'm commonly using jQuery, but weren't able to use it's scrollTop()
-Method)
So please help me!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我希望
scrollTop
正是您所寻找的(尽管我反对这种用户体验,除非有一个真正充分的理由)这个非标准)。它对我有用(live copy):
CSS:
HTML:
JavaScript w/jQuery:
I'd expect
scrollTop
to be just what you were looking for (though I would argue against this user experience barring a really good reason to be this non-standard).It works for me (live copy):
CSS:
HTML:
JavaScript w/jQuery: