Vertically centering Bootstrap modal window

前端 未结 30 2007
被撕碎了的回忆
被撕碎了的回忆 2020-12-07 07:00

I would like to center my modal on the viewport (middle) I tried to add some css properties

 .modal { position: fixed; top:50%; left:50%; }   
30条回答
  •  不知归路
    2020-12-07 07:31

    My choice, just a little CSS: ( NOT working in IE8 )

    .modal.fade .modal-dialog {
        transform: translate(-50%, -80%);
    }
    
    .modal.in .modal-dialog {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        margin-top: 0px;
    }
    

    You can play with the first rule to change how the modal appears.

    Using: Bootstrap 3.3.4

提交回复
热议问题