Bootstrap没有切换菜单

时间:2017-03-02 08:31:09

标签: html css twitter-bootstrap

我的菜单在点击时无法打开,无法理解原因。在stackoverflow和网络上检查了很多帖子,但仍然无法弄明白。问题可能是可悲的,但我仍然是引导程序的新手。

<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>




<header>
  <div class="navbar navbar-default navbar-fixed-top text-uppercase">
    <div class="container">
      <div class="navbar-header">
        <a href="index.html" class="navbar-brand">My Blog</a>

        <button type="button" class="navbar-toggle" data-toggle="collapse" data-targert=".navbar-collapse">
                                <span class="icon-bar"></span>
                                <span class="icon-bar"></span>
                                <span class="icon-bar"></span>
                            </button>
      </div>
      <div class="navbar-collapse collapse">
        <ul class="nav navbar-nav navbar-right">
          <li>
            <a href="#">Register</a>
          </li>
          <li>
            <a href="#">Login</a>
          </li>
        </ul>
      </div>
    </div>
  </div>
</header>

<footer></footer>

欢迎任何建议!谢谢!

2 个答案:

答案 0 :(得分:1)

你写了一个错字:它应该是&#34;数据目标&#34;而不是&#34;数据目标&#34; :)

<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">

在这次改变之后,它对我有用了!

答案 1 :(得分:0)

这是下拉切换菜单的示例:

 <ul class="nav navbar-nav navbar-right">
                <li class="dropdown profile_menu">
                    <a href="#" data-toggle="dropdown" class="dropdown-toggle"><span>Hello</span><b class="caret"></b></a> 
                    <ul class="dropdown-menu">
                        <li><a href="@Url.Action("Index", "Manage")">My Account</a></li>
                        <li><a href="#">Go to Profile</a></li>
                        <li><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li>
                    </ul>
                </li>
            </ul>