How to center a modal window on a page?

前端 未结 8 1690
太阳男子
太阳男子 2021-02-07 05:43

I am trying center a modal window in the browser page. I just want to center it, so that it should be responsive for all the screens.

8条回答
  •  时光说笑
    2021-02-07 06:26

    Set bootstrap modal center to screen using css only.

    .modal {
      text-align: center;
      padding: 0!important;
    }
    .modal:before {
      content: '';
      display: inline-block;
      height: 100%;
      vertical-align: middle;
      margin-right: -4px;
    }
    .modal-dialog {
      display: inline-block;
      text-align: left;
      vertical-align: middle;
    }
    

    Browsers & Screens Compatible Solution

提交回复
热议问题