Bootstrap 3 modal creates scrollbar when opened

前端 未结 13 1574
遥遥无期
遥遥无期 2020-12-10 03:03

I\'m trying to use Bootstrap for the first time and am having an issue with modal dialogs. Using the example code on this page, when the modal is opened a scrollbar appears,

相关标签:
13条回答
  • 2020-12-10 03:21

    In this case you can overwrite bootstrap main css using your own css cause sometime may effect other. so this is simple code which work

    body.modal-open .modal {
        margin-right: -15px !important;
    }
    
    body.modal-open {
        margin-right: 0 !important;
    } 
    

    if you want to change main bootstrap css then update this

    body.modal-open, .modal-open .navbar-fixed-top, .modal-open .navbar-fixed-bottom {
        margin-right: 0 !important;
    }
    
    0 讨论(0)
  • 2020-12-10 03:29

    LVarayut's answer sent me in the right direction and what I ended up using is this:

    body.modal-open, .modal-open .navbar-fixed-top, .modal-open .navbar-fixed-bottom {
        margin-right: 0;
    }
    
    .modal {
        overflow-y: auto;
    }
    
    0 讨论(0)
  • 2020-12-10 03:30

    This work for me. It should work fine

    body.modal-open { 
      padding-right: 0 !important;
      overflow-y: scroll;
    }
    
    0 讨论(0)
  • 2020-12-10 03:30

    Its mainly due to the CDN used ...Remove the CDN https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" from your page and the problem is solved..I had done it.

    0 讨论(0)
  • 2020-12-10 03:31

    Try This

      .modal-open {
             overflow-y: auto
         }
    
    0 讨论(0)
  • 2020-12-10 03:32

    This is my solution

    #myModal{
        overflow:hidden;
    }
    body {
        overflow-y: scroll !important;
    } 
    

    With this,you will force your page to have a scroll bar.

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