Bootstrap Navbar下拉菜单位置错误

时间:2015-05-02 21:40:45

标签: javascript jquery html css twitter-bootstrap

问题在于图标栏只能在小屏幕或超小屏幕上看到。当你点击图标栏时,你应该有一个下拉菜单显示图标栏,而不是它出现在标题旁边。我无法弄清楚这个问题。这是我的代码:

HTML

<div class="navbar navbar-default navbar-static-top">
  <div class="container">
    <a href="#" class="navbar-brand">Art and other cool stuff</a>
    <button class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse">
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </button>
    <div class="collapse navbar-collapse navHeaderCollapse">
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#">Home</a>
        </li>
        <li><a href="#">Swag</a>
        </li>
        <li><a href="#">WillyWonka</a>
        </li>
        <li><a href="#">Masterful</a>
        </li>
      </ul>
    </div>
  </div>
</div>

1 个答案:

答案 0 :(得分:0)

你忘了添加.navbar-header div。所以就像这样。

FIDDLE

代码:

<div class="navbar navbar-default navbar-static-top">
<div class="container">
    <div class="navbar-header">
        <a href="#" class="navbar-brand">Art and other cool stuff</a>
        <button class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>
    </div>
    <div class="collapse navbar-collapse navHeaderCollapse">
        <ul class="nav navbar-nav navbar-right">
            <li><a href="#">Home</a>
            </li>
            <li><a href="#">Swag</a>
            </li>
            <li><a href="#">WillyWonka</a>
            </li>
            <li><a href="#">Masterful</a>
            </li>
        </ul>
    </div>
</div>