Scrollbar in div scroll instead of page scrollbar

你。 提交于 2019-12-12 02:07:47

问题


I was building my site I can came across a little problem. I have a div with a fixed height and overflow:auto;. The height of the website will adjust itself to fit the page perfectly so that you dont get a scrollbar. My question is: Can I pass through the scroll event that happends in the page and redirect it to the scrollbar ? So in other words, when I scroll, not the page, but the scrollbar inside my div has to move.

I hope I made myself clear, if not, please ask for some more information.

With kindly regards, Bob

FIXED: The solution Andy brought up worked like a charm! Thank you and thanks all of you for your suggestions ^^.


回答1:


This should work, I have used it in the past:

div {
        width:150px;
        height:150px;
        overflow:scroll;
    }



回答2:


Here's an example of a possible solution:

http://jsfiddle.net/TTXqQ/

I'm using the Mousewheel Plugin




回答3:


I believe the only way to do this is by fixing the content of everything else on the page and positioning your div such that it is in the "window" framed by the fixed content. If you can post your HTML, we may be able to help more.



来源:https://stackoverflow.com/questions/6653668/scrollbar-in-div-scroll-instead-of-page-scrollbar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!