在Bootstrap 3.0 Modal中,滚动条已禁用但仍占用空间

Oma*_*riq 3 html css scrollbar twitter-bootstrap

这个问题与此有关: -

为什么在这个Bootstrap 3.0模态演示中会出现第二个垂直滚动条?

好.我已经覆盖了.modaloverflow-y规则: -

.modal {
    overflow-y: auto !important;
}
Run Code Online (Sandbox Code Playgroud)

但现在当模态打开时,我看不到滚动条.没关系.这就是我的要求.但是,它仍然占用空间,并且只要模态打开,页面就会向左移动.

截图: -

在此输入图像描述

有解决方案吗

Oma*_*riq 5

罪魁祸首抓住了.Bootstrap使用以下名称和规则向正文和其他区域添加一个类: -

body.modal-open, .modal-open .navbar-fixed-top, .modal-open .navbar-fixed-bottom {
     margin-right:15px;
}
Run Code Online (Sandbox Code Playgroud)

也如下覆盖这个类,它会没事的.

body.modal-open, .modal-open .navbar-fixed-top, .modal-open .navbar-fixed-bottom {
     margin-right:0px;
}
Run Code Online (Sandbox Code Playgroud)