导航栏中的bootstrap切换不起作用

时间:2015-06-21 18:34:32

标签: html css drop-down-menu twitter-bootstrap-3 toggle

我不是全新的引导程序,但我无法弄清楚这里的问题是什么。 我需要一个为移动设备显示的下拉菜单。我刚刚使用了getbootstrap.com导航栏中的示例并更改了一些单词。

<nav class="navbar navbar-default">
    <div class="container-fluid background_green">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <a type="button" class="btn btn-navbar navbar-toggle collapsed" data-toggle="collapse" data-target="#yourcity_1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </a>
            <a class="navbar-brand" href="index.html">YourCity</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="yourcity_1">
            <ul class="nav navbar-nav">
                <li><a href="explore.html">Explore</a></li>
                <li><a href="improve.html">Improve</a></li>

            </ul>
            <form class="navbar-form navbar-right" role="search">
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="Search YourCity">
                </div>
                <button type="submit" class="btn btn-default">Submit</button>
            </form>

        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>

这是我的头脑:

<head lang="en">
<meta charset="UTF-8">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="css/styles.css">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<title>YourCity</title>

我在这里阅读了一些帖子,但我的问题是菜单没有打开/切换。所以我可以点击3个栏,没有任何反应。

1 个答案:

答案 0 :(得分:0)

试试这个,

&#13;
&#13;
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>

<div class="container">

  <div class="dropdown">
    <button class="btn btn-default dropdown-toggle" type="button" id="menu1" data-toggle="dropdown">Tutorials
      <span class="caret"></span>
    </button>
    <ul class="dropdown-menu" role="menu" aria-labelledby="menu1">
      <li role="presentation"><a role="menuitem" tabindex="-1" href="#">HTML</a>
      </li>
      <li role="presentation"><a role="menuitem" tabindex="-1" href="#">CSS</a>
      </li>
      <li role="presentation"><a role="menuitem" tabindex="-1" href="#">JavaScript</a>
      </li>
      <li role="presentation" class="divider"></li>
      <li role="presentation"><a role="menuitem" tabindex="-1" href="#">About Us</a>
      </li>
    </ul>
  </div>
</div>
&#13;
&#13;
&#13;