我试图在bootstrap 4中获得一个模态页脚,以获得多个100%宽度的行。因此,对于下面最基本的bootstrap模式示例,是否可以将Close和Save更改按钮设置在不同的行上,并且两者都是100%宽度?
<div class="modal fade" id="exampleModalLong" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div><div class="modal-body">
...
</div><div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
答案 0 :(得分:5)
是的,您确定可以放置两个modal-footer
元素。
<div class="modal fade" id="exampleModalLong" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div><div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button col-lg-12" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
<div class="modal-footer">
<button type="button col-lg-12" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
然后在你的CSS中添加这个
#exampleModalLong .modal-footer .btn{
width:100%;
}
这里有jsfillde link
答案 1 :(得分:2)
一种更“自然”的方法是添加
.modal-footer {
display: block;
}
这是默认的display: flex
,使按钮共享同一行。