lucas clemente lucas clemente - 4 months ago 15
HTML Question

Deactivate body's scrolling but keep scroll bar

How do I disable

body
's scroll bar, but let it stay visible on screen? As an example see facebook's theatre mode:

facebook screen

Answer

This is the only CSS you will ned to force the scrollbars:

html{
    overflow-y: scroll;
}

The scrollbars will be disabled if the content is smaller than the window, so you will have to use some script to resize the body to be at least 1px less then the window height:

$("body").css({ "height" : ($(window).height() - 1) + 'px', "overflow": "hidden" });