twitter bootstrap 3 和 bootswatch 平面模板 - 模态不再工作

gol*_*ife 2 css modal-dialog twitter-bootstrap bootswatch bootstrap-modal

在我从 bootswatch ( https://bootswatch.com/flatly/ )安装平面模板后,twbs 的正常模式窗口不再工作。

<a data-toggle="modal" href="#" data-target="#myModal">CLICK!</a>
.
.
        <!-- Modal -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">Modal title</h4>
              </div>
              <div class="modal-body">
                ...
              </div>
              <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary">Save changes</button>
              </div>
            </div>
          </div>
        </div>

    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

在我将主题添加到我的应用程序中之前,它工作得很好。

这意味着模式窗口会出现,但并未处于活动状态。模态窗口出现在灰色背景后面。模态窗口没有焦点。我也关不掉 但为什么?

小智 5

Bootstrap 在其变量文件中设置以下项目的 z-index:

@zindex-navbar:            1000;
@zindex-dropdown:          1000;
@zindex-popover:           1060;
@zindex-tooltip:           1070;
@zindex-navbar-fixed:      1030;
@zindex-modal-background:  1040;
@zindex-modal:             1050;
Run Code Online (Sandbox Code Playgroud)

bootswatch 变量文件中项目的 z 索引设置如下:

@zindex-navbar:            1000;
@zindex-dropdown:          1000;
@zindex-popover:           1060;
@zindex-tooltip:           1070;
@zindex-navbar-fixed:      1030;
@zindex-modal:             1040;
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,bootswatch 模态设置在与 bootstrap 模态背景相同的索引上。这种冲突正在引发问题。将 bootswatch 模态的 z-index 设置为 1050 将解决您的问题,或者在站点样式表中添加覆盖 .modal z-index 也会有所帮助。

.modal {z-index: 1050;}
Run Code Online (Sandbox Code Playgroud)