我使用过bootstrap但是对flexbox css来说是一种新的东西。
我有自举模式,通常有标题,正文和页脚。我想改变模型体类,如果内容太大,那么它将是可滚动的,将模型标题和模型页脚保持在固定位置。我想过使用flexbox css,但我不确定它是如何工作的。我使用了下面的flexbox css属性
模板:
<div class="modal-header">
<!-- contents.. -->
</div>
<div class="modal-body">
<!-- contents.. -->
</div>
<div class="modal-footer">
<!-- contents.. -->
</div>
的CSS:
.modal-content {
display: flex;
flex-direction: column;
max-height: calc(100vh - 60px);
}
.modal-body {
overflow: auto;
}
.modal-header, .modal-footer {
flex-grow: 1;
flex-shrink: 0;
flex-basis: auto;
}
我将模型内容作为最大视口高度--60px。这在IE中工作正常。内容可见并且溢出。我不知道解决这个问题的最佳方法
任何建议,评论都将受到赞赏!
答案 0 :(得分:1)
这是一个简单的修复,您将max-height: calc(100vh - 60px);
添加到modal-content
选择器,将其删除并将其添加到modal-body
选择器
CSS
.modal-content {
display: flex;
flex-direction: column;
}
.modal-body {
overflow: auto;
max-height: calc(100vh - 60px);
}
.modal-header, .modal-footer {
flex-grow: 1;
flex-shrink: 0;
flex-basis: auto;
}
模态
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
This Is header
</div>
<div class="modal-body">
This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content This is content
</div>
<div class="modal-footer">
This is footer
</div>
</div>
</div>
</div>
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>