jQuery - 使用窗口滚动条滚动 DIV 内的内容
是否可以使用窗口滚动条来滚动大的 DIV 内容?而不是它自己的 div 滚动条?
Is it possible to use window scrollers to scroll a big DIV content? instead of its own div scroller?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
类似于
Something like
使用 Windows 滚动条作为单独的元素
使用标准浏览器滚动条作为单独的元素似乎非常简单
用于任何目的的滚动条。
您只需要 3 个
以及一些 CSS 参数:
container-div
:将
scrollbox-div
重新定位到左侧一点(否则 content-div保持可见)。
scrollbox-div
:scrollbox-div
获取滚动条,因为它包含contents-div
,其中大于
scrollbox-div
。scrollbox-div
相对重新定位到左侧 (-24px),因此
contents-div
在container-div
中不可见。contents-div
不能比33 px
小很多,否则滚动条在 IE 中消失。contents-div
:contents-div
比srollbox-div
更大以强制滚动条。它不包含任何内容,因此它将是不可见的
通过更改
container+scrollbox-height
和content-height
你可以更改滚动条手柄大小。
只需通过更改参数进行实验即可。
使用一些jquery,您可以获取/设置
scrolltop-value
。所以有了这个参数和一些jquery 你可以选择你想要显示的数据的任何部分。
HTML:
CSS:
JQUERY:
Use Windows scrollbar as separate element
It appears to be very simple to use de standard browser scrollbar as a seperate
scrollbar for any purpose.
You just need 3
<div>
with some CSS-parameters:container-div
:to reposition the
scrollbox-div
a little bit to the left (otherwise the content-divstays visible).
scrollbox-div
:The
scrollbox-div
gets the scrollbar, because it contains thecontents-div
, whichis larger then the
scrollbox-div
. Thescrollbox-div
is relative-repositioned tothe left (-24px), so the
contents-div
is not visible in thecontainer-div
.The
contents-div
can not be made much smaller then about33 px
, otherwise the scrollbar disappears in IE.contents-div
:The
contents-div
is larger then thesrollbox-div
to force a scrollbar.It contains NOTHING, so it will be invisible
By changing the
container+scrollbox-height
and thecontent-height
you canchange the scrollbar handle size.
Just experiment by changing the parameters.
With some jquery you can get/set the
scrolltop-value
. So with this parameter and somejquery you can select any part of data you want to display.
HTML:
CSS:
JQUERY:
由于滚动条仅影响整个页面,而不影响特定元素,因此不会..至少在不完全替换滚动条的情况下不会(强烈建议不要这样做)。
Since the scrollbar only affects the overall page, and not a specific element, no.. at least not without replacing the scrollbar entirely (strongly discouraged).