Bootstrap模态框全屏问题

3

有很多解决方案可以将高度和宽度设置为100%,但这些解决方案没有考虑模态框下面的内容。
在我的jsfiddle示例中存在一个错误,我错在哪里了?

.modal-dialog {
  width: 100%;
  height: 100%;
  padding: 0;
  margin: 0;
}

.modal-content {
  height: 100%;
  border-radius: 0;
}

这里是 jsfiddle

2个回答

2
问题在于高度属性设置为100%只会填满窗口的高度。应该使用min-height代替:

.modal-dialog {
    width: 100%;
    min-height: 100%;
    padding: 0;
    margin: 0;
}

更新的示例网页


2
我找到了一个可行的解决方案,并且更新了我的jsfiddle。 点击这里 查看。
.modal {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    overflow: hidden;
}
.modal-dialog {
    position: fixed;
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
}
.modal-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    border: none;
}
.modal-content {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 0;
    box-shadow: none;
}
.modal-body {
    position: absolute;
    top: 50px;
    bottom: 0;
    font-size: 15px;
    overflow: auto;
    margin-bottom: 60px;
    padding: 0 15px 0;
    width: 100%;
}
.modal-footer {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 60px;
    padding: 10px;
    background: #f1f3f5;
}
/* to delete the scrollbar */
/*
::-webkit-scrollbar {
    -webkit-appearance: none;
    background: #f1f3f5;
    border-left: 1px solid darken(#f1f3f5, 10%);
    width: 10px;
}
::-webkit-scrollbar-thumb {
    background: darken(#f1f3f5, 20%);
}
*/

只需要一次更改就能适应我的需求,模态框的左边默认从屏幕中央开始,我在.modal-dialog中添加了 left: 0;,然后它完美地工作了,谢谢。 - sairfan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接