I have just used the css fix below and it is working for me
body { padding-right: 0 !important }
This might be a glitch from Bootstrap modal. From my tests, it seems like the problem is that #adminPanel
is being initialized while #loginModal
has not been totally closed yet. The workarounds can be removing the animation by removing the fade
class on #adminPanel
and #loginModal
or set a timeout (~500ms) before calling $('#adminPanel').modal();
. Hope this helps.
.modal-open {
padding-right: 0px !important;
}
Just changed to
.modal {
padding-right: 0px !important;
}
A pure CSS solution that keeps the bootstrap functionality as it should be.
body:not(.modal-open){
padding-right: 0px !important;
}
The problem is caused by a function in the bootstrap jQuery that adds a bit of padding-right when a modal window opens if there is a scroll bar on the page. That stops your body content from shifting around when the modal opens, and it's a nice feature. But it's causing this bug.
A lot of the other solutions given here break that feature, and make your content shift slightly about when the modal opens. This solution will preserve the feature of the bootstrap modal not shifting content around, but fix the bug.
If you're more concerned about the padding-right
related thing then you can do this
jQuery:
$('#loginModal').on('show.bs.modal', function (e) {
$('body').addClass('test');
});
this will addClass
to your body
and then using this
CSS:
.test[style] {
padding-right:0 !important;
}
and this will help you to get rid of padding-right
.
But if you're also concerned about the hiding scroll
then you've to add this too:
CSS:
.test.modal-open {
overflow: auto;
}
Here's the JSFiddle
Please have a look, it will do the trick for you.
Just open bootstrap.min.css
Find this line (default)
.modal-open{overflow:hidden;}
and change it as
.modal-open{overflow:auto;padding-right:0 !important;}
It will work for every modal of the site. You can do overflow:auto; if you want to keep scrollbar as it is while opening modal dialog.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With