0

Is there any way to scroll a div from the main page scrollbar ?

Here is an example of the page I would like to change: Scroll bar example page

Or can we put the div MAINDIV inside another div which would be 100% height and width, and scrolling this div would scroll the MAINDIV div ?

defacto
  • 359
  • 1
  • 5
  • 18
  • possible duplicate of [Scroll particular DIV contents with browser's main scrollbar](http://stackoverflow.com/questions/6887112/scroll-particular-div-contents-with-browsers-main-scrollbar) – artm Oct 26 '14 at 10:45

1 Answers1

0

Remove "overflow-y:scroll" (and "height: 580px" to make it look better) from the MAINDIV.

Removing "overflow-y" will remove the scrollbar from the MAINDIV, because you want this scrolling to apply to the body not the MAINDIV.

AND

replace "overflow-y: none" of the body by "overflow-y: auto". Now a scrollbar should appear if your MAINDIV content does not fit the browser.

Rob Monhemius
  • 4,822
  • 2
  • 17
  • 49
  • I need to set the div height to 580px. I did the changes you proposed me: [link](http://boxfly.free.fr/test/body-scroll-2.html) but as you can see, the content of the div goes beyond the div itself. – defacto Oct 26 '14 at 19:23
  • 1
    You can not add a scrollable scrollbar along the edge of your browser if the content isn't longer (580px in your case) than the screen height (there is nothing to scroll in that case). You would end up with your starting situation. You can however add another div in front of yours so you cannot see the content. like this:
    – Rob Monhemius Oct 26 '14 at 20:05