admin管理员组文章数量:1401947
I have searched everywhere and have yet to get a solution. Okay heres the deal, I have a one page website which has several div elements underneath each other, sort of acting like individual pages I guess. What I want to achieve is to disable the scrolling of the actual web page all together, yet keeping the scroll of the active div in play if it goes below the web browser. To get to each other section of the page is simple done by using anchor links on the header.
I have searched everywhere and have yet to get a solution. Okay heres the deal, I have a one page website which has several div elements underneath each other, sort of acting like individual pages I guess. What I want to achieve is to disable the scrolling of the actual web page all together, yet keeping the scroll of the active div in play if it goes below the web browser. To get to each other section of the page is simple done by using anchor links on the header.
Share Improve this question asked Oct 24, 2012 at 21:39 Muhammed BhikhaMuhammed Bhikha 5,0199 gold badges37 silver badges47 bronze badges 1- What is the question? Can we see some sample code? – Jason Commented Oct 24, 2012 at 21:50
3 Answers
Reset to default 4I'm not exactly sure what you're looking for, but I think you want a div to be scrollable, but not the actual document. You can do this by absolutely positioning the div on the screen with a fixed height and set the overflow
to auto
. I've done this using the following CSS code:
#scrollable {
position: absolute;
top: 10px;
right: 10px;
bottom: 10px;
left: 10px;
overflow: auto;
}
See an example: http://jsfiddle/rustyjeans/rgzBE/
Have you tried with
overflow-x:hidden;
turns out its quite simple. CSS
body{
overflow:hidden;
}
#div_you_need_scrolling{
overflow:auto;
}
本文标签:
版权声明:本文标题:javascript - Disable the body scroll, but keep it on individual div elements which are greater in height than the browser - Stac 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744312682a2600105.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论