Bootstrap 3 modal vertical position center

后端 未结 30 1188
天涯浪人
天涯浪人 2020-11-28 00:15

This is a two part question:

  1. How can you position the modal vertically in the center when you don\'t know the exact height of the modal?

  2. Is

30条回答
  •  抹茶落季
    2020-11-28 00:52

    .modal {
      text-align: center;
    }
    
    @media screen and (min-width: 768px) { 
      .modal:before {
        display: inline-block;
        vertical-align: middle;
        content: " ";
        height: 100%;
      }
    }
    
    .modal-dialog {
      display: inline-block;
      text-align: left;
      vertical-align: middle;
    }
    

    And adjust a little bit .fade class to make sure it appears out of the top border of window, instead of center

提交回复
热议问题