Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to vertical-center Twitter Bootstrap 3 modal?

I've been trying to vertical center the Boostrap 3 modal dialog without sucess. How can that be accomplished?

like image 595
Rui Avatar asked Sep 27 '13 02:09

Rui


People also ask

How do I center a bootstrap modal vertically?

Thanks v.d for pointing out you need to add both . modal-dialog-centered to . modal-dialog to vertically center the modal. This is the best answer for bootstrap 4.

How do I center vertically in Bootstrap 3?

Another way to vertically center is to use my-auto . This will center the element within its container. For example, h-100 makes the row full height, and my-auto will vertically center the col-sm-12 column. Since Bootstrap 4 .


1 Answers

You can achieve vertical alignment center on Bootstrap 3 modal like that :

.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 */
}

and add this css class to the "modal-dialog" container

<div class="modal-dialog modal-vertical-centered">
...

jsFiddle working example : http://jsfiddle.net/U4NRx/

like image 114
EGurelli Avatar answered Oct 20 '22 04:10

EGurelli