Bootstrap Boostrap模式宽度不适用于响应主题

lf5gs5x2  于 2022-12-07  发布在  Bootstrap
关注(0)|答案(4)|浏览(129)

Please don't delete or close this question I put my question here after full three days search.
My responsive website has many modals to display blocks of data. The modal works fine with the default width on browser and small devices.
When I increase modal width for browsers with in % (percentage) it works fine in only browser. But do not display properly in mobile phones and other devices.
I tried % with min-width etc etc but no luck... also boostrap modal documentation has no information regarding size. only there is a small and large size is available which do not fit to my requirements.
Secondly I am oppening the modals using JS code as:

$(".modal-body").html("Loading...");
        $(".modal-body").load("fdeed.php");
        $("#modal_appointments").modal();
        $('#modal_appointments').modal('show');

Please, help me how I change the width so that it works fine in all devices. Any kind of help is highly appreciated. Thank you.

6ioyuze2

6ioyuze21#

如果你使用的是bootstrap 3.1.0,尝试使用bootstrap提供的类,以便在较小的设备中使用模态。我个人从未在极小设备中测试过它。尝试使用.modal-dialog类的以下类
.modal-sm-适用于小型设备。
.modal-lg-适用于较大的装置。
有用的链接
http://codepen.io/SitePoint/pen/KkHyw
希望能有所帮助,

pkmbmrz7

pkmbmrz72#

将容器宽度设置为60%,覆盖边距并设置左侧位置应该可以满足您的需要:

<div id="myModal" class="modal fade" tabindex="-1" role="dialog" style="left: 20%; width: 60%; margin-left: 0px;">
   <div class="modal-dialog">

您可以在以下位置找到完整的示例:http://www.bootply.com/I0V4kQgcMD
使用右边的移动的预览按钮在一个可以调整大小的新窗口中查看它。

rbpvctlc

rbpvctlc3#

可以通过编程方式调整最大宽度。

var m = $('#modal_appointments');
m.css('width', '850px');
m.css('max-width', '100%');
m.css('margin', '50px auto 50px auto');
m.modal('show');
7ivaypg9

7ivaypg94#

首先,不要给modal给予宽度,如果您使用@media query,只需删除
删除modal-lg,然后它将工作

相关问题