Trying to make bootstrap modal wider

后端 未结 3 389
醉话见心
醉话见心 2021-01-30 09:55

I am using this code but the modal is too thin:

相关标签:
3条回答
  • 2021-01-30 10:35

    You could try:

    .modal.modal-wide .modal-dialog {
      width: 90%;
    }
    
    .modal-wide .modal-body {
      overflow-y: auto;
    }
    

    Just add .modal-wide to your classes

    0 讨论(0)
  • 2021-01-30 10:42

    If you need this solution for only few types of modals just use style="width:90%" attribute.

    example:

    div class="modal-dialog modal-lg" style="width:90%"
    

    note: this will change only this particular modal

    0 讨论(0)
  • 2021-01-30 10:55

    Always have handy the un-minified CSS for bootstrap so you can see what styles they have on their components, then create a CSS file AFTER it, if you don't use LESS and over-write their mixins or whatever

    This is the default modal css for 768px and up:

    @media (min-width: 768px) {
      .modal-dialog {
        width: 600px;
        margin: 30px auto;
      }
      ...
    }
    

    They have a class modal-lg for larger widths

    @media (min-width: 992px) {
      .modal-lg {
        width: 900px;
      }
    }
    

    If you need something twice the 600px size, and something fluid, do something like this in your CSS after the Bootstrap css and assign that class to the modal-dialog.

    @media (min-width: 768px) {
      .modal-xl {
        width: 90%;
       max-width:1200px;
      }
    }
    

    HTML

    <div class="modal-dialog modal-xl">
    

    Demo: http://jsbin.com/yefas/1

    0 讨论(0)
提交回复
热议问题