Yet another CSS solution. Does not Work for popups that are bigger than the view port.
.modal-dialog {
position: absolute;
right: 0;
left: 0;
margin-top: 0;
margin-bottom: 0;
}
.modal.fade .modal-dialog {
transition: top 0.4s ease-out;
transform: translate(0, -50%);
top: 0;
}
.modal.in .modal-dialog {
transform: translate(0, -50%);
top: 50%;
}
In .modal-dialog
class overriding the position to absolute(from relative) and centering the content right:0, left: 0
In .modal.fade .modal-dialog , .modal.in .modal-dialog
setting the transition animation over top
rather than on translate.
margin-top
moves the popup slightly below the center in case of small popup and in case of long popups, the modal is stuck with header. Hence margin-top:0, margin-bottom:0
Need to further refine it.