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

标签 css twitter-bootstrap modal-dialog bootstrap-modal bootswatch

在我从 bootswatch ( https://bootswatch.com/flatly/) 安装 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>

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

这意味着模态窗口出现了,但它不是事件的。 模态窗口出现在灰色背景后面。模态窗口没有焦点。我也关不掉 但是为什么?

最佳答案

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;

bootswatch 变量文件中元素的 z-index 设置如下:

@zindex-navbar:            1000;
@zindex-dropdown:          1000;
@zindex-popover:           1060;
@zindex-tooltip:           1070;
@zindex-navbar-fixed:      1030;
@zindex-modal:             1040;

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

.modal {z-index: 1050;}

关于css - Twitter bootstrap 3 和 bootswatch 平面模板 - 模态不再工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29144858/

相关文章:

javascript - Chrome/Opera 闪烁绘画问题

javascript - 当使用 jQuery slideDown 显示父元素时,Microsoft Edge 中的子元素不可见

php - Laravel - 在 Blade 中使用函数

javascript - 灵活宽度居中模态窗口

javascript - 如何加载 leanmodal div 内容 onclick

html - 带 anchor 和按钮的盒子模型

php - Drupal 元素类

html - 在此 Bootstrap 示例中,调整大小时如何解释对齐方式

css - 修改Rails的custom.scss.css导致报错

internet-explorer - IE 的 jQuery UI 对话框问题