I'm using twitter bootstrap for a project I am working on.
I have a modal window that has a somewhat longer form in it and I didn't like that when the window got too small the modal didn't scroll (if just disappeared off my page which isn't scrollable).
To fix this I used the following css
.modal { overflow-y:auto; max-height:90%; margin-top:-45%; }
This works exactly the way I want it to in Chrome (that is, the form is full size when the window is big enough, but as the window shrinks the modal shrinks and becomes scrollable). The problem is that in IE the modal is off the screen. Does anyone have a better solution to this problem?
My example can be found at tinyhousemap.com (click 'Add an Entry to the map' in the navigation window for the modal to appear)
Thanks
Bootstrap 4.3 added new built-in scroll feature to modals. This makes only the modal-body content scroll if the size of the content would otherwise make the page scroll. To use it, just add the class modal-dialog-scrollable to the same div that has the modal-dialog class.
The .modal-header class is used to define the style for the header of the modal. The <button> inside the header has a data-dismiss="modal" attribute which closes the modal if you click on it.
When the Button is clicked, the HTML DIV is referenced using jQuery and its modal function is called along with properties data-backdrop: "static" and data-keyboard: false which disables the closing of the Bootstrap Modal Popup when clicked outside.
On each of your <tr> 's add a data attribute for id (i.e. data-id ) with the corresponding id value and specify a data-target , which is a selector you specify, so that when clicked, bootstrap will select that element as modal dialog and show it.
How about the below solution? It worked for me. Try this:
.modal .modal-body { max-height: 420px; overflow-y: auto; }
Details:
overflow-y: auto;
or overflow: auto;
from .modal class (important)max-height: 400px;
from .modal
class (important)max-height: 400px;
to .modal .modal-body (or what ever, can be 420px
or less, but would not go more than 450px
)overflow-y: auto;
to .modal .modal-body
Done, only body will scroll.
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