How to prevent background scrolling when Bootstrap 3 modal open on mobile platforms? On desktop browsers the background is prevented from scrolling and works as it should.
On mobile browsers (Safari ios, Chrome ios, etc), when a modal is opened and using your finger to scroll it, the background also scrolls as does the modal. How do I prevent that?
As additional to @Karthick Kumar answer from bootstrap docs
... so it should be:
I open a modal after a modal and fact the error on modal scrolling, and this css solved my problem:
Prevents the background from scrolling without any fuss.
Also prevents page jumping around from missing scrollbars
I've found a simple javascript/jquery solution which utilizes the bootstrap modal events.
My solution also fixes the
position:fixed
problem where it scrolls the background page all the way back to the top instead of staying in place when modal window is opened/closed.See details here
I know this has been answered but none of these solutions worked for me. I needed to take a different approach. I am using PhoneGap and am compiling my code natively so I had to move the background to the body. I hope this helps someone else. Or if there a cleaner way to do this please feel free to comment...
See here: https://github.com/twbs/bootstrap/issues/7501
So try:
V3.0.0. should have fixed this issue. Do you use the latest version? If so post an issue on https://github.com/twbs/bootstrap/