javascript - Disable the body scroll, but keep it on individual div elements which are greater in height than the browser - Stac

I have searched everywhere and have yet to get a solution. Okay heres the deal, I have a one page websi

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
Add a ment  | 

3 Answers 3

Reset to default 4

I'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;
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744312682a4568024.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信