简体   繁体   English

固定水平滚动条

[英]Fixed Horizontal Scroll Bar

Ok, so here's what I have: http://jsfiddle.net/E2U3j/ 好的,这就是我所拥有的: http : //jsfiddle.net/E2U3j/

And as it's a pretty large div, I'd like to have a fixed horizontal scroll bar on the top of the window when I'm scrolling into that div, but if I'm not completely into the div (eg If the div is only visible a half,I mean if it doesn't fill the whole height of the window), the horizontal scroll bar should be in the top of the div... How would you solve this? 而且由于它是一个相当大的div,所以当我滚动到该div时,我想在窗口顶部有一个固定的水平滚动条,但是如果我没有完全进入div(例如,如果div是仅可见一半,我的意思是,如果它不填满整个窗口的高度),则水平滚动条应位于div的顶部...您将如何解决此问题? Thanks :) 谢谢 :)

这段代码应该可以解决您的问题<div id="topnav" style="position:fixed; max-height:x; overflow-y:scroll;"></div>那么您顶部导航栏的内容就可以在其自身内滚动固定在页面顶部

Try jQuery Scrollbar with external scrollbar (available on advaced scrollbars demo page) - scrollbar can be placed in any part of your page, you can hide/show it, make it fixed, etc... 尝试使用带有外部滚动条的jQuery Scrollbar (可在高级滚动条演示页上使用)-滚动条可以放置在页面的任何部分,您可以隐藏/显示它,使其固定等。

The one thing you need is to handle window scroll and check current scroll position, compare it to your container offset and if it's greater - make scrollbar fixed, if not - change position to absolute (in case when scrollbar is inside of your container). 您需要做的一件事是处理窗口滚动并检查当前滚动位置,将其与您的容器偏移量进行比较,如果更大,则将滚动条固定,如果不固定,则将位置更改为绝对位置(以防滚动条位于容器内部)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM