我是新手。实际上,我已经尝试了所有的解决方案,所以,我问这个问题。
我的模型CSS是
#orphanModal{
.modal-body{
min-height: 450px;
margin-bottom: 10px;
}
.modal-footer {
margin: 0;
padding: 8px 14px;
font-size: 14px;
font-weight: 400;
background: #f1f1f1;
border-top: 1px solid #e0e0e0;
border-radius: 6px;
}
.modal-dialog{
width: 700px;
}
.modal-close, .modal-close:hover{
color: #000000;
font-weight: bolder;
font-size: 24px;
}
.modal-header{
height: 60px;
}
}
我的模型是我们从 bootstarp 站点获取的默认模型。 谁能告诉我我的 CSS 有什么问题吗?
我试过了
.modal-dialog {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) !important;
}
还有。但没有运气。谢谢。
最佳答案
要垂直对齐任何东西,在这种情况下是模态的,你可以这样做:
.modal{
position: relative;
top: 50;
transform: translateY(-50%);
}
Notice: This will work if parent element have position relative.
这也会在您调整大小时对齐元素。
关于javascript - 如何垂直居中引导模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51535590/