Reputation: 99
I'm trying to vertically align the Bootstrap Modal using CSS (or other solution that might be even more elegant than that).
I already tried
.modal-dialog {
display: inline-block;
text-align: left;
vertical-align: middle;
}
but no luck. The modal displays to the left top.
Thanks!
Upvotes: 1
Views: 42
Reputation: 86
.modal-dialog {
position: absolute;
margin: 0;
transform: translate(-50%,-50%) !important;
-webkit-transform: translate(-50%,-50%) !important;
-moz-transform: translate(-50%,-50%) !important;
-o-transform: translate(-50%,-50%) !important;
-ms-transform: translate(-50%,-50%) !important;
top: 50%;
left: 50%;
}
Above will all prefixes
Upvotes: 0
Reputation: 2229
Try to use next code:
.modal-dialog {
position: absolute;
margin: 0;
transform: translate(-50%,-50%) !important;
/* ^ dont forget to prefixize this ^ */
top: 50%;
left: 50%;
}
Upvotes: 3