Code Web Design

iOS prevent scrolling on body

Ordinarily, overflow: hidden; on the body tag is sufficient to prevent scrolling a web page, if for instance you’re creating a drawer to hold content that will scroll separately. However, this doesn’t work in iOS6. The best I’ve come up with so far is to set position: fixed:

body.lock-position {
height: 100%;
overflow: hidden;
width: 100%;
position: fixed;

3 replies on “iOS prevent scrolling on body”

Nice discovery! Thank you.
Can you suggest something to keep current window scroll?
It is being reset when setting body to fixed.

Hi Ed,
I tried using your trick to keep the page non scrollable when the menu opens up in mobile. But on the first click of menu, the menu takes up fixed position and it is only on the second click that the menu opens. Please help in knowing what I am doing wrong.

Comments are closed.