简体   繁体   English

导航栏崩溃在Bootstrap上不起作用

[英]Navbar collapse not working on Bootstrap

I cannot get to work the navbar collapse in Bootstrap 3. 我无法启动Bootstrap 3中的导航栏折叠。

My menu collapse nicely when I change screensize, only it won't show the menu when I press the button. 当我更改屏幕尺寸时,我的菜单会很好地折叠,但是当我按下按钮时,它不会显示菜单。

This is my code: 这是我的代码:

<header class="container">
  <div id="menu" class="navbar navbar-default">
      <div class="navbar-header">
          <button class="btn btn-success navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
              <span class="glyphicon glyphicon-chevron-down"></span>
          </button>
      <div id="logo">
          <a href='..'><h3>Logo</h3></a>
        </div>
     </div>
      <div class="navbar-collapse collapse">
          <ul class="nav navbar-nav navbar-right">
              <li class="nav active"><a href=".">Home</a>
              </li>
              <li class="nav"><a href="about.html">About</a>
              </li>
              <li class="nav"><a href="contact.html">Contact</a>
              </li>
          </ul>
      </div>
  </div>
</header>

The issue is not in the HTML your code works perfect in this Fiddle 问题不在HTML中,您的代码在此Fiddle中无法完美运行

Check this fiddle 检查这个小提琴

make sure you include the responsive css 确保您包括响应式CSS

http://getbootstrap.com/dist/css/bootstrap.css

and the correct JS 和正确的JS

http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js

Your HTML works fine, so make sure you are referencing the proper scripts and and styles in your markup 您的HTML可以正常运行,因此请确保您在标记中引用了正确的脚本和样式

Make sure you have the following in your markup: 确保标记中包含以下内容:

Fiddle Works Fine 小提琴作品很好

Copy and paste this HTML: 复制并粘贴以下HTML:

<link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.min.css">
<script type="text/javascript" src="//code.jquery.com/jquery-2.0.2.js"></script>
<script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>

I also suffered from the same problem, and could not find the solution anywhere. 我也遇到了同样的问题,无法在任何地方找到解决方案。 Actually bootstrap.min.js needs jquery to work. bootstrap.min.js实际上需要jquery才能工作。 SO if you put script src=js/bootstrap.min.js before script src=js/jquery.js it will not work. 因此,如果将脚本src = js / bootstrap.min.js放在脚本src = js / jquery.js之前,它将不起作用。 The Order of inclusion of jquery and bootstrap.min.js is important . 包含jquery和bootstrap.min.js的顺序很重要

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM