我已经直接从Bootstrap示例中使用了我的模态代码,并且只包括Bootstrap .js(而不是Bootstrap -modal.js)。但是,我的模态出现在灰色渐隐(背景)下面,是不可编辑的。

这是它的样子:

这是重现这个问题的一种方法。该代码的基本结构是这样的:

<body>
    <p>Lorem ipsum dolor sit amet.</p>    

    <div class="my-module">
        This container contains the modal code.
        <div class="modal fade">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-body">Modal</div>
                </div>
            </div>
        </div>
    </div>
</body>
body {
    padding-top: 50px;
}

.my-module {
    position: fixed;
    top: 0;
    left: 0;
}

你知道为什么会这样吗或者我能做些什么来弥补吗?


当前回答

我只在iOS设备上遇到过类似的问题。

解决方案是从父元素中删除-webkit-overflow-scrolling: touch

其他回答

在你的情态动词中使用:

data-backdrop="false" 

检查你的css,看看你是否有任何模糊和过滤器。我从css中删除了这段代码,模态再次正常工作

.modal-open .main-wrapper {
    -webkit-filter: blur(1px);
    -moz-filter: blur(1px);
    -o-filter: blur(1px);
    -ms-filter: blur(1px);
    filter: blur(1px);
}

你也可以从.modal- background中删除z索引。生成的css看起来像这样。

.modal-backdrop {
}
  .modal-backdrop.in {
    opacity: .35;
    filter: alpha(opacity=35); }

当在CSS中为背景或甚至是手风琴头使用渐变之类的东西时,经常会遇到这个问题。

不幸的是,修改或覆盖核心的Bootstrap CSS是不可取的,并且可能导致不需要的副作用。侵入性最小的方法是添加data- background ="false",但您可能会注意到渐隐效果不再像预期的那样工作。

继Bootstrap的最新版本之后,3.3.5版本似乎解决了这个问题,并且没有不必要的副作用。

下载:https://github.com/twbs/bootstrap/releases/download/v3.3.5/bootstrap-3.3.5-dist.zip。

确保包含3.3.5中的CSS文件和JavaScript文件。

根据之前的答案,这可能有几个原因。 对我来说,问题是在不知情的情况下引用两个不同的Bootstrap链接,所以删除一个就解决了问题。

在我的例子中,我包括了这个:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.5/css/bootstrap.min.css"
      integrity="sha384-AysaV+vQoT3kOAXZkl02PThvDr8HYKPZhNT5h/CXfBThSRXQ6jW5DO2ekP5ViFdi" crossorigin="anonymous">

还有一个离线的,我的笔记本电脑里已经有了。