添加命名空间后,Bootstrap 模式不起作用

Gad*_*hev 5 css jquery namespaces twitter-bootstrap bootstrap-modal

我在 bootstrap css 文件中添加了命名空间以避免冲突。但是,在那之后,模态无法正常工作。添加的内容没有被我的命名空间 div 包围,所以它不起作用。

下面是一个例子:

<div class="ssl">
    <button type="button" class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-sm">Small modal</button>
</div>
<div class="ssl">
    <div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
      <div class="modal-dialog modal-sm">
        <div class="modal-content">
      This is the modal content.
        </div>
      </div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我使用此代码通过 less 添加命名空间:

.ssl {
    @import (less) 'bootstrap-full.css';
}
Run Code Online (Sandbox Code Playgroud)

任何人都可以通过提出一些想法来帮助我解决这个问题吗?

小智 2

在 Bootstrap 4.1 中添加命名空间后,我找到了这个问题的解决方案。您必须从模态背景类中删除命名空间,基本上,将其更改为:

.namespace .modal-backdrop {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1040;
  background-color: #000;
}

.namespace .modal-backdrop.fade {
  opacity: 0;
}

.namespace .modal-backdrop.show {
  opacity: 0.5;
}
Run Code Online (Sandbox Code Playgroud)

对此:

.modal-backdrop {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1040;
  background-color: #000;
}

.modal-backdrop.fade {
  opacity: 0;
}

.modal-backdrop.show {
  opacity: 0.5;
}
Run Code Online (Sandbox Code Playgroud)

就我而言,自定义引导程序是在容器内部使用的,而不是整个页面,因此当我创建模态时,会在容器外部创建一个新的分区,超出自定义 CSS 的范围。