how to change the default positioning of modal in bootstrap?

后端 未结 5 1060
陌清茗
陌清茗 2021-01-31 02:28
相关标签:
5条回答
  • 2021-01-31 02:43

    If you need to change the bottom position of the modal, you need to modify the max-height of the modal-body:

    .modal-body {
      max-height: 75vh;
    }
    

    As other answers have said, you can adjust the right and top on the modal-dialog :

    .modal-dialog {
      top: 10vh;
      right: 5vw;
    }
    
    • "vh" means "% of view height"
    • "vw" means "% of view width"
    0 讨论(0)
  • 2021-01-31 02:46

    To change the Modal position in the viewport you can target the Modal div id, in this example this id is myModal3

        <div id="modal3" class="modal">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h4 class="modal-title">Modal title</h4>
          </div>
          <div class="modal-body">
            <p>One fine body…</p>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
            <button type="button" class="btn btn-primary">Save changes</button>
          </div>
        </div>
      </div>
    </div>
    
    
    #myModal3 {
    top:5%;
    right:50%;
    outline: none;
    overflow:hidden;
    }
    
    0 讨论(0)
  • 2021-01-31 02:47

    I get a better result setting this class:

    .modal-dialog {
      position: absolute;
      top: 50px;
      right: 100px;
      bottom: 0;
      left: 0;
      z-index: 10040;
      overflow: auto;
      overflow-y: auto;
    }
    

    With bootstrap 3.3.7.

    (all credits to msnfreaky for the idea...)

    0 讨论(0)
  • 2021-01-31 02:56

    I know it's a bit late but I had issues with a modal window not allowing some links on the menu bar to work, even when it has not been triggered. But I solved it by doing the following:

    .modal{
    display:none;
    }
    
    0 讨论(0)
  • 2021-01-31 02:57

    Add the following css to your html and try changing the top, right, bottom, left values.

    .modal {
       position: absolute;
       top: 10px;
       right: 100px;
       bottom: 0;
       left: 0;
       z-index: 10040;
       overflow: auto;
       overflow-y: auto;
    }
    
    0 讨论(0)
提交回复
热议问题