If I open a modal dialog, through Twitter Bootstrap, I've noticed that it pushes all the html content of the page (i.e., in the container
) to the left a little bit, and then puts it back to normal after closing itself. However, this only happens if the browser width is large enough to not be on the "mobile" (i.e., smallest) media query. This occurs with the latest versions of FF and Chrome (haven't tested other browsers).
You can see the problem here: http://jsfiddle.net/jxX6A/2/
Note: You have to increase the width of the "Result" window so it switches to the "med" or "large" media query css.
I have setup the HTML of the page based upon the examples shown on Bootstrap's site:
<div class='container'>
<div class='page-header'>
<h4>My Heading</h4>
</div>
<div id='content'>
This is some content.
</div>
<div class='footer'>
<p>© 2013, me</p>
</div>
</div>
I'm guessing this is not supposed to happen, but I'm not sure what I've done wrong.
EDIT: This is a known bug, for more (and up-to-date) information, please see: https://github.com/twbs/bootstrap/issues/9855
You just edit .modal-open class form bootstrap.min.css file, I thin it's will be ok
.modal-open{overflow:auto}
The over-flow:hidden is set there , you just set over-flow:auto .
I use Bootstrap v3.3.4 and see this problem, I understood that Bootstrap modal add 17px padding right to the body, so just simply use following code:
So it turns out I was actually getting right margin of 250px or so. My problem seemed to be that .modal-open was getting set to position: fixed, and that was the cause for whatever reason. So in my case, the fix was similar, but I set the position value to the default as below:
Here's what I used, will work 100% in Bootstrap 3.2.0 as long as you don't mind forcing scrollbars.
For bootstrap 3.x.x.
I have found a solution, that works with 100% CSS and no JavaScript.
The trick is, show the scrollbar for modal over the scrollbar of html content.
CSS:
here is an online example: http://jsbin.com/oHiPIJi/43/
I test it on Windows 7 with:
One new little issues I could find with IE:
IE has background (=body) scrolling with mouse wheel, if nothing more to scroll in the foreground.
Care about
position:fixed
!Because of the nature of this workaround, you need extra care for fixed elements. For example the padding for "navbar fixed" need to be set to
html
and not tobody
(how it is described in bootstrap doc).alternative with wrapper
If you do not like set
overflow:hidden
onhtml
(some people don´t want this, but it works, is valid and 100% standard compliant), you can wrap the content ofbody
in an extra div.Than you do not need extra care for fixed elements, you can use it like before.
here is an example: http://jsbin.com/oHiPIJi/47/
Update:
Issues in Bootstrap:
Update 2: FYI
In Bootstrap 3.2.0 they add a workaround to
modal.js
that try to handle the issues with Javascript for every invoke ofmodal.prototype.show()
,Modal.prototype.hide()
andModal.prototype.resize()
. They add 7 (!) new methods for that. Now ca. 20% of code frommodal.js
only try to handle that issues.When the model opens, a padding of 17px to the right of the body. The code below should resolve that issue.