Vertically centering Bootstrap modal window

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

    The best solution to centralize your modal with width and height is, in css add and in modal add this 'centralize' as a class..

    .centralize{
       position:absolute;
       left:50%;
       top:50%;
    
       background-color:#fff;
       transform: translate(-50%, -50%);
       width: 40%; //specify watever u want
       height: 50%;
       }
    

提交回复
热议问题