Quantcast
Channel: Prevent BODY from scrolling when a modal is opened - Stack Overflow
Viewing all articles
Browse latest Browse all 60

Answer by AdamJB for Prevent BODY from scrolling when a modal is opened

$
0
0

I'm not 100% sure this will work with Bootstrap but worth a try - it worked with Remodal.js which can be found on github: http://vodkabears.github.io/remodal/ and it would make sense for the methods to be pretty similar.

To stop the page jumping to the top and also prevent the right shift of content add a class to the body when the modal is fired and set these CSS rules:

body.with-modal {
    position: static;
    height: auto;
    overflow-y: hidden;
}

It's the position:static and the height:auto that combine to stop the jumping of content to the right. The overflow-y:hidden; stops the page from being scrollable behind the modal.


Viewing all articles
Browse latest Browse all 60

Latest Images

Trending Articles



Latest Images