我已经直接从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;
}

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


当前回答

这种行为有时发生在有未关闭标记时,尤其是未关闭</div>。你可以检查你的模式的位置,确保所有的标签都是正确关闭的,或者更好的是将div模式移动到页面底部,在</body>标签框之前

其他回答

在CSS中添加这些对我来说是一种技巧。

.modal-backdrop.fade.show{
   z-index:0;
}

角:

($('.modal-backdrop') as any).remove();

在我的情况下,我有一个包装与以下:

.wrapper { margin: 0 auto; position:relative; z-index:1;overflow:hidden;}

只删除了z-index:1,不知道为什么要修复这个问题。当然也可以移除相对位置,但我需要它。

和Davide Lorigliola一样,我通过提高z指数来解决这个问题:

.modal-backdrop { z-index: -999999; }

我发现:

在bootstrap 3.3.0中这是不正确的,但在bootstrap 3.3.5中这是正确的。让我们看看代码。 3.3.0:

this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
    .prependTo(this.$element)

3.3.5

  this.$backdrop = $(document.createElement('div'))
        .addClass('modal-backdrop ' + animate)
        .appendTo(this.$body)