Bootstrap NavBar响应式怪异

时间:2015-02-24 02:06:04

标签: twitter-bootstrap-3

我有一个使用Boostrap 3.2的页面。当我重新调整窗口大小(chrome)以触发响应式设计时,导航栏的行为非常奇怪。它可以工作一次,但任何后续调用根本不起作用。

enter image description here

奇怪的是,我无法在jsFiddle中表现出同样的行为。所以,我将介绍保管箱链接

https://dl.dropboxusercontent.com/u/3740186/test/publications.html

导航栏的HTML

  <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
    <div class="container">
      <!-- Brand and toggle get grouped for better mobile display -->
      <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="./Index.html">
          <img src="./images/logo_big.png" width="30" height="30" title="PIT" alt="PIT" />
          Test Pitt
        </a>
      </div>
      <!-- Collect the nav links, forms, and other content for toggling -->
      <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
        <ul class="nav navbar-nav navbar-right">
          <li>
            <a href="./publications.html">Home</a>
          </li>
          <li>
            <a href="./publications.html">Members</a>
          </li>

          <li>
            <a href="./publications.html">Research</a>
          </li>

          <li>
            <a href="./publications.html">Publications</a>
          </li>

          <li class="active">
            <a href="./publications.html">Teaching</a>
          </li>
        </ul>
      </div>
      <!-- /.navbar-collapse -->
    </div>
    <!-- /.container -->
  </nav>

由于

1 个答案:

答案 0 :(得分:2)

最后你的脚本出了问题。

$('.collapse').on('shown.bs.collapse', function (e) {
  $("#" + e.target.id.replace("abs_", "btn_")).html("<span class=\"glyphicon glyphicon-collapse-up\" aria-hidden=\"true\"></span> &nbsp; Hide Abstract");
});

$('.collapse').on('hidden.bs.collapse', function (e) {
  $("#" + e.target.id.replace("abs_", "btn_")).html("<span class=\"glyphicon glyphicon-collapse-down\"aria-hidden=\"true\"></span> &nbsp; Show Abstract");
});

您可以将这些事件添加到所有.collapse元素,其中包括重新调整窗口大小时的菜单。