1

安装 jPanelMenu jQuery 插件后,我在 Twitter Bootstrap 中显示模式窗口时遇到问题。

问题是打算在模型后面的背景出现在模态之前。

背景的 z-index 是 1040,模态窗口的 z-index 是 1050,两者都设置为 position:fixed,所以一切都应该正确显示。

我发现了几个关于模态背景堆叠顺序问题的过去主题,但没有一个涉及 jPanel,我无法使用任何建议的解决方案。

运行 jPanel 插件清楚地引入了该问题,因为删除脚本库时它会消失。但是我不知道如何在启用 jPanel 的情况下解决它,因为它不会对 z-index 的变化做出反应,除非您将背景的 z-index 运行到 < 2 并且它完全消失。我在这里制作了一个显示问题的 JSFiddle:

http://jsfiddle.net/funkylaundry/DebF6/3/light/

<body>

  <div class="navbar navbar-inverse navbar-fixed-top">
    <div class="navbar-inner">
      <div class="container-fluid">
        <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="brand" href="#">Project name</a>
        <div class="nav-collapse collapse">
          <p class="navbar-text pull-right">
            Logged in as
            <a href="#" class="navbar-link">Username</a>
          </p>
          <ul class="nav">
            <li>
              <a class="menu-trigger" href="#">Menu</a>
            </li>
            <li class="active">
              <a href="#">Home</a>
            </li>
            <li>
              <a href="#about">About</a>
            </li>
            <li>
              <a href="#contact">Contact</a>
            </li>
          </ul>
        </div>
        <!--/.nav-collapse --> </div>
    </div>
  </div>

  <div class="container-fluid">
    <div class="row-fluid">
      <div class="span9">
        <div class="hero-unit">
          <h1>Hello, world!</h1>
          <p>
            This is a template for a simple marketing or informational website. It includes a large callout called the hero unit and three supporting pieces of content. Use it as a starting point to create something more unique.
          </p>
          <p>
            <!-- Button to trigger modal -->
            <a href="#myModal" role="button" class="btn btn-primary btn-large" data-toggle="modal">Launch demo modal</a>
              <hr>
              <a href="#myModal" role="button" class="btn btn-primary btn-large menu-trigger">Launch jPanel Menu</a>
          </p>
            <!-- Modal -->
  <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
      <h3 id="myModalLabel">Modal header</h3>
    </div>
    <div class="modal-body">
      <p>One fine body…&lt;/p>
    </div>
    <div class="modal-footer">
      <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
      <button class="btn btn-primary">Save changes</button>
    </div>
  </div>
        </div>
        <div class="row-fluid">
          <div class="span4">
            <h2>Heading</h2>
            <p>
              Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.
            </p>
            <p>
              <a class="btn" href="#">View details &raquo;</a>
            </p>
          </div>
          <!--/span-->
          <div class="span4">
            <h2>Heading</h2>
            <p>
              Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.
            </p>
            <p>
              <a class="btn" href="#">View details &raquo;</a>
            </p>
          </div>
          <!--/span-->
          <div class="span4">
            <h2>Heading</h2>
            <p>
              Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.
            </p>
            <p>
              <a class="btn" href="#">View details &raquo;</a>
            </p>
          </div>
          <!--/span--> </div>
        <!--/row-->
        <div class="row-fluid">
          <div class="span4">
            <h2>Heading</h2>
            <p>
              Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.
            </p>
            <p>
              <a class="btn" href="#">View details &raquo;</a>
            </p>
          </div>
          <!--/span-->
          <div class="span4">
            <h2>Heading</h2>
            <p>
              Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.
            </p>
            <p>
              <a class="btn" href="#">View details &raquo;</a>
            </p>
          </div>
          <!--/span-->
          <div class="span4">
            <h2>Heading</h2>
            <p>
              Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui.
            </p>
            <p>
              <a class="btn" href="#">View details &raquo;</a>
            </p>
          </div>
          <!--/span--> </div>
        <!--/row--> </div>
      <!--/span--> </div>
    <!--/row-->

    <hr>

    <footer>
      <p>&copy; Company 2013</p>
    </footer>

  </div>
  <nav class="span3" id="menu" style="display:none;">
    <div id="navigator" class="navigation row-fluid">
      <div class="navbox">

        <ul class="nav nav-list">
          <li>
            <a href="/">Listen</a>
          </li>
          <li>
            <a href="/Playlist">Playlists</a>
          </li>
          <li>
            <a href="#">Charts</a>
          </li>
          <li>
            <a href="/Account/Manage">My Profile</a>
          </li>
        </ul>

      </div>

    </div>

  </nav>



  <!--/.fluid-container-->

  <!-- Le javascript
    ================================================== -->
  <!-- Placed at the end of the document so the pages load faster -->
  <script src="js/jquery.js"></script>
  <script src="js/jquery.jpanelmenu.js"></script>
  <script src="js/bootstrap.js"></script>
  <script>
      $('document').ready(function(){
        var jPM = $.jPanelMenu();
        jPM.on();
      });
    </script>

</body>
4

2 回答 2

3

jPanelMenu 插件将所有内容推送到一个.jPanelMenu-paneldiv 中,该 div 的 z-index 为 2。这最终与 Bootstrap 模态元素的 z-index 冲突,如图所示。

jPanelMenu 有一个名为 excludePanelContent 的选项

一个选择器字符串,指定<body>不应将元素中的哪些元素推入.jPanelMenu-panel。选择器字符串可以包含任何选择器,而不仅仅是标签。

通常,<style>标签<script>不应从其原始位置移动,但在某些情况下(主要是广告),<script>标签可能需要随页面内容移动。

数据类型: string

默认值: style, script

一种解决方案是排除<body>包含 Bootstrap 模态标记的最顶层元素。在您的情况下,我将首先重新定位模态标记,使其成为您的顶级元素<body>,然后排除.modal

var jPM = $.jPanelMenu({
  excludedPanelContent: 'style, script, .modal'
});

重新定位模态标记是必要的,以便可以独立排除它;您的主要内容 div 仍然需要被推入.jPanelMenu-panel,以便 jPanel 菜单切换正常工作。

请参阅http://jsfiddle.net/DebF6/7/上的更新小提琴

于 2013-09-30T16:25:14.897 回答
0

只需将此 CSS 代码添加到您的网站。

.modal-open .jPanelMenu-panel{position:static!important;transform:none!important;}

打开引导模式时,它将禁用 jPanelMenu 覆盖,以防止它们之间发生冲突。

祝你好运!

于 2015-09-22T08:05:22.513 回答