Vertically centering Bootstrap modal window

前端 未结 30 1997
被撕碎了的回忆
被撕碎了的回忆 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:34

    The top parameter is being overridden in .modal.fade.in to force the value set in your custom declaration, add the !important keyword after top. This forces the browser to use that value and ignore any other values for the keyword. This has the drawback that you can't override the value anywhere else.

    .modal {
        position: fixed;
        top: 50% !important;
        left: 50%;
    }
    

提交回复
热议问题