我一直试图将Bootstrap 3模态对话框垂直居中,但没有成功。怎么能实现呢?
答案 0 :(得分:6)
您可以在Bootstrap 3模式上实现垂直对齐中心:
.modal-vertical-centered {
transform: translate(0, 50%) !important;
-ms-transform: translate(0, 50%) !important; /* IE 9 */
-webkit-transform: translate(0, 50%) !important; /* Safari and Chrome */
}
并将此css类添加到“模态对话框”容器
<div class="modal-dialog modal-vertical-centered">
...
jsFiddle工作示例:http://jsfiddle.net/U4NRx/
答案 1 :(得分:0)
<style>
.modal-vertical-centered {
display: flex;
align-items: center;
}
</style>
<div class="modal fade modal-vertical-centered" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">