Disable Scrolling on Body

user4532193 picture user4532193 · Feb 9, 2015 · Viewed 463.4k times · Source

I would like to disable scrolling on the HTML body completely. I have tried the following options:

  • overflow: hidden; (not working, did not disable scrolling, it just hid the scrollbar)

  • position: fixed; (this worked, but it scrolled completely to the top, which is unacceptable for this specific application)

I was unable to find any alternatives to these two options, are there any more?

Answer

pavel picture pavel · Feb 9, 2015

Set height and overflow:

html, body {margin: 0; height: 100%; overflow: hidden}

http://jsfiddle.net/q99hvawt/