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

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


当前回答

.modal-backdrop {
/* bug fix - no overlay */    
display: none;}

其他回答

在你的导航栏navbar-fixed-top需要z-index = 1041 如果你使用bootstarp-combined.min.css,也需要将。navbar-fixed-top, .navbar-fixed-bottom z-index改为1041

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

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

尝试将类.modal-open overflow值从隐藏重写为可见:

.modal-open {
    overflow: visible;
}

最简单的解决方案是将模态对话框移到任何容器之外,并在<body>元素下声明它:

<body>    
    <div>
        ...
    <div>
    
    
    <div class="modal">
        ... modal dialog here
    </div>
</body>

我试过这个方法,对我很有效。

来源:https://weblog.west-wind.com/posts/2016/sep/14/bootstrap-modal-dialog-showing-under-modal-background

你可以做一个变通,但这将从所有页面删除淡出。模态会像Facebook弹出窗口一样弹出。 打开模态尝试后:

 $('.modal-backdrop').removeClass('modal-backdrop');