我不能让bootstrap下拉列表工作

时间:2017-10-24 14:36:48

标签: html twitter-bootstrap-3

我在bootstrap的下拉列表中遇到问题。我已正确附加所有必要的文件。但它还是不起作用。

<nav class="navbar navbar-default navbar-inverse">
<div class="navbar-header">
    <button type="button" class="navbar-toggle" data-target="#mainNavbar" data-toggle="collapse">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
    </button>
</div>
<div class="navbar-collapse collapse" id="mainNavbar">
    <ul class="nav navbar-nav">
        <li class="active"><a href="#">Home</a></li>
        <li><a href="#">Contact</a></li>
        <li><a href="#">About</a></li>
        <li><a href="#">Products</a></li>
    </ul>
    <form class="navbar-form navbar-left" role="search">
        <div class="form-group">
            <input type="text" class="form-control" placeholder="Search">
        </div>
        <button type="button" class="btn btn-default">Submit</button>
    </form>
    <ul class="nav navbar-nav navbar-right">
        <li><a href="#">Subscribe</a></li>
    </ul>
</div>

1 个答案:

答案 0 :(得分:0)

确保您放置jquerybootstrap的顺序正确无误。检查下面的代码段是否正常。

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<nav class="navbar navbar-default navbar-inverse">
  <div class="navbar-header">
    <button type="button" class="navbar-toggle" data-target="#mainNavbar" data-toggle="collapse">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
    </button>
  </div>
  <div class="navbar-collapse collapse" id="mainNavbar">
    <ul class="nav navbar-nav">
      <li class="active"><a href="#">Home</a></li>
      <li><a href="#">Contact</a></li>
      <li><a href="#">About</a></li>
      <li><a href="#">Products</a></li>
    </ul>
    <form class="navbar-form navbar-left" role="search">
      <div class="form-group">
        <input type="text" class="form-control" placeholder="Search">
      </div>
      <button type="button" class="btn btn-default">Submit</button>
    </form>
    <ul class="nav navbar-nav navbar-right">
      <li><a href="#">Subscribe</a></li>
    </ul>
  </div>