Bootstrap modal makes scrollbar disappear after closing
I had the same problem.
Bootstrap add modal-open
class in the body
, but does not remove when the modal is closed.
I solved just adding in callback:
$('body').removeClass('modal-open');
bootstrap modal removes scroll bar
This is a feature, class modal-open
gets added to the HTML body
when you show the modal, and removed when you hide it.
This makes the scrollbar disappear since the bootstrap css says
.modal-open {
overflow: hidden;
}
You can override this by specifying
.modal-open {
overflow: scroll;
}
in your own css.
Background scrollbar disappears when opening modal
Every time the Modal opens, class .modal-open
is added to the body
tag - and this class contains overflow:hidden
.
This can be fixed by adding this:
.modal-open {
overflow: inherit;
}
Now you'll find that opening the Modal suddenly causes a scroll to the bottom; which is also why the Button was disappearing from view on every click...
You'll probably have to experiment further to prevent the scrolling from happening, it could be because the div or something in it gets focus just before it is shown as a modal.
Scrollbar disappearing when use modal on Bootstrap
Add
divName.modal-open {
overflow: scroll;
}
this will work in v3 of bootstrap
Modal Closes, but scroll bar doesn't come back
To help anyone else who may run into this. Upon further inspection of the DOM after the modal closed I noticed that body still had this class applied: ".modal-open".
Removal of this class would bring the page back to normal conditions. The following simple line of code attached to the onclick event solved this issue (although I still haven't figured out the underlying cause).
$('body').removeClass('modal-open');
Related Topics
Low Power Mode Detection in JavaScript for iOS11
How to Dynamically Change the Value of a CSS Property Inside a Stylesheet
Trigger Same CSS Animation on Every Click
Using Variables in Gulp for the Destination File Name
Uncaught Syntaxerror: Unexpected Token Illegal
How to Prevent iOS Safari Alert When Trying to Open Non-Installed Native App
Get Actual Value Specified in CSS Using Jquery
How to Position Popover Over a Highlighted Portion of Text
How to Grab the CSS Truncated Text via Jquery
Wkwebview Evaluate JavaScript Return Value
Webkit Transitionend Event Grouping
Detect If Visitor Is on Index Page with Client Side Scripting
Ios9: Try to Open App via Scheme If Possible, or Redirect to App Store Otherwise
Using Environment Variables/Parameterizing Config.Xml
Disable Select Option in iOS Safari