Bootstrap 3 modal fires and causes page to shift to the left momentarily / browser scroll bar problems

后端 未结 24 1468
遥遥无期
遥遥无期 2020-12-12 12:08

I am working on a site using Bootstrap 3.1.0.

You\'ll notice when the modal window opens, the browser scroll bar just disappears for a split second, then comes back.

24条回答
  •  南方客
    南方客 (楼主)
    2020-12-12 13:05

    For Bootstrap-4.3.x use the following css:

    .modal-open {
        padding-right: 0 !important;
    }
    
    /* if you have .navbar in your page then add padding-right for your .navbar (default is 16px) */
    .modal-open .navbar {
        padding-right: 16px !important;
    }
    

    That's it. Nothing else is needed like: JavaScript code to add some .class in your body and then adding CSS codes to style them.

提交回复
热议问题