Old post. I ended up setting media queries and using max-width: YYpx;
and width:auto;
for each breakpoint. This will scale w/ images as well (per say you have an image that's 740px width on the md
screen), the modal will scale down to 740px (excluding padding for the .modal-body
, if applied)
<div class="modal fade" id="bs-button-info-modal" tabindex="-1" role="dialog" aria-labelledby="Button Information Modal">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<div class="modal-body"></div>
</div>
</div>
</div>
Note that I'm using SCSS, bootstrap 3.3.7, and did not make any additional edits to the _modals.scss
file that _bootstrap.scss
imports. The CSS below is added to an additional SCSS file and imported AFTER _bootstrap.scss
.
It is also important to note that the original bootstrap styles for .modal-dialog
is not set for the default 992px breakpoint, only as high as the 768px breakpoint (which has a hard set width applied width: 600px;
, hence why I overrode it w/ width: auto;
.
@media (min-width: $screen-sm-min) { // this is the 768px breakpoint
.modal-dialog {
max-width: 600px;
width: auto;
}
}
@media (min-width: $screen-md-min) { // this is the 992px breakpoint
.modal-dialog {
max-width: 800px;
}
}
Example below of modal being responsive with an image.