How to DISABLE scrollbar in webpage? (not HIDE scrollbar)

前端 未结 4 658
情歌与酒
情歌与酒 2021-01-08 01:17

using:

$(\'body,html\').css(\"overflow\",\"hidden\");

the scrollbar in the page was able to hide completely. But i want the scroll bar just

4条回答
  •  青春惊慌失措
    2021-01-08 01:40

    If you want to disable the scrollbar click- and drag-function you can render a hidden div in front of the scrollbar with position: fixed; top: 0; right: 0; height: 100%; width: 25px;

    http://jsfiddle.net/Bg9zp/ (htm-class could be your html/body)

    So it is disabled for clicks, but the scroll-functionality is'nt disabled. (you can scroll with mousewheel and with "select text by pulling mouse out of the textbox")

    If you want to disable the scroll-functionality, you have to add another div that disable user input without the "disabled-opacity":

    http://jsfiddle.net/dKP53/ (htm-class could be your html/body)

提交回复
热议问题