Disable elastic scrolling in Safari

Fabian Leutgeb picture Fabian Leutgeb · Nov 16, 2011 · Viewed 151k times · Source

I just wanted to diable the elastic scrolling/bounce effect in Safari (OSX Lion).

I found the solution to set overflow: hidden for body in css, but as expected it only disables the scrollbar, so if the website is "longer" than the screen you won't be able to scroll!

Any solutions or hints are welcome! Thanks!

Answer

Aintaer picture Aintaer · May 2, 2013

You can achieve this more universally by applying the following CSS:

html,
body {
  height: 100%;
  width: 100%;
  overflow: auto;
}

This allows your content, whatever it is, to become scrollable within body, but be aware that the scrolling context where scroll event is fired is now document.body, not window.