Twitter Bootstrap,导航栏,下拉不能正常工作

时间:2015-11-28 21:55:40

标签: javascript jquery html css twitter-bootstrap

我正在尝试使用bootstrap制作响应式导航栏。但是,下拉菜单无法正常工作。

我希望在品牌名称下面没有下拉。

这是我的代码:

<html>
<head>
<meta name="viewport" content="width=device-width, intial-scale=1.0">
<link href="css/bootstrap.min.css" type="text/css" rel="stylesheet">
</head>
<body>
<div class="navbar navbar-inverse navbar-static-top">
    <div class="container">
        <a href="#" class="navbar-brand">ACUPRESSURE</a>

        <button type="button" class = "navbar-toggle" data-toggle ="collapse" data-target = ".navHeaderCollapse">
        <span class="sr-only">Toggle navigation</span>
        <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 ="#">Home</a></li>
                <li><a href ="#">Home</a></li>
                <li><a href ="#">Home</a></li>
                <li><a href ="#">Home</a></li>
            </ul>
        </div>          
    </div>
</div>
<script src= "http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script>
<script src= "js/bootstrap.js"></script>
</body>
</html>

1 个答案:

答案 0 :(得分:2)

您错过了navbar-headernavbar-toggle周围的navbar-brand课程。请参阅Docs

工作示例。

&#13;
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="navbar navbar-inverse navbar-static-top">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse"> <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>

      </button><a href="#" class="navbar-brand">ACUPRESSURE</a>

    </div>
    <div class="collapse navbar-collapse navHeaderCollapse">
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#">Home</a>

        </li>
        <li><a href="#">Home</a>

        </li>
        <li><a href="#">Home</a>

        </li>
        <li><a href="#">Home</a>

        </li>
        <li><a href="#">Home</a>

        </li>
      </ul>
    </div>
  </div>
</div>
&#13;
&#13;
&#13;