Answers:
我在Bootstrap 3中使用以下代码实现了这一目标:
.modal-dialog {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.modal-content {
height: auto;
min-height: 100%;
border-radius: 0;
}
通常,当您对间距/填充问题有疑问时,请尝试右键单击(或在Mac上为cmd +单击)该元素,然后在Chrome上选择“检查元素”,在Firefox上选择“检查带有萤火虫的元素”。尝试在“元素”面板中选择不同的HTML元素,并在右侧实时编辑CSS,直到获得所需的填充/间距。
.modal-content
当内容在底部溢出并向下滚动时,的高位中断。应该是min-height: 100%; height: auto;
.modal-dialog
还需要max-width: 100%;
为引导4
所选解决方案不保留圆角样式。要保留圆角,应稍微减小宽度和高度,并删除边界半径0。而且它不显示垂直滚动条...
.modal-dialog {
width: 98%;
height: 92%;
padding: 0;
}
.modal-content {
height: 99%;
}
我想出了一种用于全屏模式的“响应式”解决方案:
全屏模式只能在某些断点上启用。这样,模态将在较宽的(桌面)屏幕上显示“正常”,而在较小的(平板电脑或移动设备)屏幕上显示全屏,给人以本地应用程序的感觉。
为Bootstrap 3和Bootstrap 4实施。
以下通用代码应该起作用:
.modal {
padding: 0 !important; // override inline padding-right added from js
}
.modal .modal-dialog {
width: 100%;
max-width: none;
height: 100%;
margin: 0;
}
.modal .modal-content {
height: 100%;
border: 0;
border-radius: 0;
}
.modal .modal-body {
overflow-y: auto;
}
通过包含下面的scss代码,它生成需要添加到.modal
元素的以下类:
+---------------+---------+---------+---------+---------+---------+
| | xs | sm | md | lg | xl |
| | <576px | ≥576px | ≥768px | ≥992px | ≥1200px |
+---------------+---------+---------+---------+---------+---------+
|.fullscreen | 100% | default | default | default | default |
+---------------+---------+---------+---------+---------+---------+
|.fullscreen-sm | 100% | 100% | default | default | default |
+---------------+---------+---------+---------+---------+---------+
|.fullscreen-md | 100% | 100% | 100% | default | default |
+---------------+---------+---------+---------+---------+---------+
|.fullscreen-lg | 100% | 100% | 100% | 100% | default |
+---------------+---------+---------+---------+---------+---------+
|.fullscreen-xl | 100% | 100% | 100% | 100% | 100% |
+---------------+---------+---------+---------+---------+---------+
scss代码是:
@mixin modal-fullscreen() {
padding: 0 !important; // override inline padding-right added from js
.modal-dialog {
width: 100%;
max-width: none;
height: 100%;
margin: 0;
}
.modal-content {
height: 100%;
border: 0;
border-radius: 0;
}
.modal-body {
overflow-y: auto;
}
}
@each $breakpoint in map-keys($grid-breakpoints) {
@include media-breakpoint-down($breakpoint) {
$infix: breakpoint-infix($breakpoint, $grid-breakpoints);
.modal-fullscreen#{$infix} {
@include modal-fullscreen();
}
}
}
Codepen上的演示:https ://codepen.io/andreivictor/full/MWYNPBV/
根据以前对此主题的答复(@Chris J,@ kkarli),以下通用代码应该可以工作:
.modal {
padding: 0 !important; // override inline padding-right added from js
}
.modal .modal-dialog {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.modal .modal-content {
height: auto;
min-height: 100%;
border: 0 none;
border-radius: 0;
box-shadow: none;
}
如果要使用自适应全屏模式,请使用以下需要添加到.modal
element的类:
.modal-fullscreen-md-down
-对于小于的屏幕,模式为全屏显示1200px
。.modal-fullscreen-sm-down
-对于小于的屏幕,模式为全屏显示922px
。.modal-fullscreen-xs-down
-模态为全屏显示,屏幕小于768px
。看下面的代码:
/* Extra small devices (less than 768px) */
@media (max-width: 767px) {
.modal-fullscreen-xs-down {
padding: 0 !important;
}
.modal-fullscreen-xs-down .modal-dialog {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.modal-fullscreen-xs-down .modal-content {
height: auto;
min-height: 100%;
border: 0 none;
border-radius: 0;
box-shadow: none;
}
}
/* Small devices (less than 992px) */
@media (max-width: 991px) {
.modal-fullscreen-sm-down {
padding: 0 !important;
}
.modal-fullscreen-sm-down .modal-dialog {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.modal-fullscreen-sm-down .modal-content {
height: auto;
min-height: 100%;
border: 0 none;
border-radius: 0;
box-shadow: none;
}
}
/* Medium devices (less than 1200px) */
@media (max-width: 1199px) {
.modal-fullscreen-md-down {
padding: 0 !important;
}
.modal-fullscreen-md-down .modal-dialog {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.modal-fullscreen-md-down .modal-content {
height: auto;
min-height: 100%;
border: 0 none;
border-radius: 0;
box-shadow: none;
}
}
演示可在Codepen上获得:https ://codepen.io/andreivictor/full/KXNdoO 。
那些使用Sass作为预处理器的人可以利用以下mixin:
@mixin modal-fullscreen() {
padding: 0 !important; // override inline padding-right added from js
.modal-dialog {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
.modal-content {
height: auto;
min-height: 100%;
border: 0 none;
border-radius: 0;
box-shadow: none;
}
}
以下课程将在Bootstrap中制作全屏模式:
.full-screen {
width: 100%;
height: 100%;
margin: 0;
top: 0;
left: 0;
}
我不确定模态的内部内容的结构,这可能会对整体高度产生影响,具体取决于与之关联的CSS。
用于自举4
添加类:
.full_modal-dialog {
width: 98% !important;
height: 92% !important;
min-width: 98% !important;
min-height: 92% !important;
max-width: 98% !important;
max-height: 92% !important;
padding: 0 !important;
}
.full_modal-content {
height: 99% !important;
min-height: 99% !important;
max-height: 99% !important;
}
和在HTML中:
<div role="document" class="modal-dialog full_modal-dialog">
<div class="modal-content full_modal-content">
您需要如下设置DIV标签。
查找更多详细信息> http://thedeveloperblog.com/bootstrap-modal-with-full-size-and-scrolling
</style>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
More Details
</button>
</br>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-content">
<div class="container">;
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h3 class="modal-title" id="myModalLabel">Modal Title</h3>
</div>
<div class="modal-body" >
Your modal text
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
我的解决方案的变体:(scss)
.modal {
.modal-dialog.modal-fs {
width: 100%;
margin: 0;
box-shadow: none;
height: 100%;
.modal-content {
border: none;
border-radius: 0;
box-shadow: none;
box-shadow: none;
height: 100%;
}
}
}
(css)
.modal .modal-dialog.modal-fs {
width: 100%;
margin: 0;
box-shadow: none;
height: 100%;
}
.modal .modal-dialog.modal-fs .modal-content {
border: none;
border-radius: 0;
box-shadow: none;
box-shadow: none;
height: 100%;
}
.modal.in .modal-dialog {
width:100% !important;
min-height: 100%;
margin: 0 0 0 0 !important;
bottom: 0px !important;
top: 0px;
}
.modal-content {
border:0px solid rgba(0,0,0,.2) !important;
border-radius: 0px !important;
-webkit-box-shadow: 0 0px 0px rgba(0,0,0,.5) !important;
box-shadow: 0 3px 9px rgba(0,0,0,.5) !important;
height: auto;
min-height: 100%;
}
.modal-dialog {
position: fixed !important;
margin:0px !important;
}
.bootstrap-dialog .modal-header {
border-top-left-radius: 0px !important;
border-top-right-radius: 0px !important;
}
@media (min-width: 768px)
.modal-dialog {
width: 100% !important;
margin: 0 !important;
}
用这个:
.modal-full {
min-width: 100%;
margin: 0;
}
.modal-full .modal-content {
min-height: 100vh;
}
所以:
<div id="myModal" class="modal" role="dialog">
<div class="modal-dialog modal-full">
<!-- Modal content-->
<div class="modal-content ">
<div class="modal-header ">
<button type="button" class="close" data-dismiss="modal">×
</button>
<h4 class="modal-title">hi</h4>
</div>
<div class="modal-body">
<p>Some text in the modal.</p>
</div>
</div>
</div>
</div>
margin: 0
到.modal-dialog
。