jQuery:我如何滚动的身体而不显示滚动条? [英] jQuery: How do I scroll the body without showing the scroll bar?
问题描述
我想通过使用 overflow:hidden;
隐藏文档的滚动条(在一些浏览器中它是body元素,在其他浏览器中它是html元素) 。然后我使用jQuery.animate()来尝试和动画scrollTop属性。当滚动条可见时(即没有 overflow:hidden;
样式),它工作正常,但是当滚动条隐藏时,它不工作。这是为什么?
I'm trying to hide the scroll bar of the document (in some browsers it's the body element, in others it's the html element) by using overflow:hidden;
. Then i'm using jQuery.animate() to try and animate the scrollTop property. It works fine when the scroll bar is visible (i.e. without the overflow:hidden;
style) but doesn't work when the scroll bar is hidden. Why is that? I'll be able to post a link to a snapshot of the problematic page in a bit...
推荐答案
尝试make < body>
overflow:hidden
,并为 margin-top
属性,注意如果你想要一个正的scrollTop, margin-top
应该阴性。
Try make <body>
overflow:hidden
and animate the margin-top
property, note the margin-top
should be negative if you want a positive scrollTop.
在webkit上,你可以使用 :: - webkit-scrollbar:{display:none; }
隐藏启用了滚动功能的滚动条。
On webkit you could use ::-webkit-scrollbar: { display: none; }
to hide the scrollbar with scroll features enabled.
这篇关于jQuery:我如何滚动的身体而不显示滚动条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!