我已经直接从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>标签框之前

其他回答

我简单地设置了:

#myModal {
    z-index: 1500;
}

它工作....

对于原来的问题:

.my-module {
    z-index: 1500;
}

但是迟了,这里有一个通用的解决方案

    var checkeventcount = 1,prevTarget;
    $('.modal').on('show.bs.modal', function (e) {
        if(typeof prevTarget == 'undefined' || (checkeventcount==1 && e.target!=prevTarget))
        {  
          prevTarget = e.target;
          checkeventcount++;
          e.preventDefault();
          $(e.target).appendTo('body').modal('show');
        }
        else if(e.target==prevTarget && checkeventcount==2)
        {
          checkeventcount--;
        }
     });

访问这个链接-当使用固定的侧边栏时,引导3模式在背景下消失。

我有这个问题,最简单的解决方法是在modal-dialog div上添加z-index大于1040:

<div class="modal-dialog" style="z-index: 1100;">

我相信bootstrap创建了一个div模态背景淡出,在我的情况下,z指数为1040,所以如果你把模态对话框放在上面,它应该不再是灰色的。

我让它通过在打开模态窗口后给它一个高z指数值来工作。例如:

$("#myModal").modal("show");
$("#myModal").css("z-index", "1500");

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

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