Bootstrap中的Dropdown Navbar无法正常工作

时间:2022-06-03 19:03:36

When the navbar is resized, the dropdown doesn't seem to work. Is there anything wrong with my codes? Is there any solution for this?

调整导航栏的大小时,下拉列表似乎不起作用。我的代码有什么问题吗?这有什么解决方案吗?

This is my HTML code.

这是我的HTML代码。

<!-- Fixed navbar -->
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="home.php">company</a>
    </div>
    <div class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
        <li class="active"><a href="home.php"><i class="glyphicon glyphicon-home"></i><span>&nbsp;Home</span></a></li>
        <li><a href="order.php"><i class="glyphicon glyphicon-pencil"></i><span>&nbsp;Order</span></a></li>
        <li><a href="cart.php"><i class="glyphicon glyphicon-shopping-cart"></i><span>&nbsp;Cart</span></a></li>
        <li><a href="contactus.php"><i class="glyphicon glyphicon-earphone"></i><span>&nbsp;Contact Us</span></a></li>
        <li><a href="about.php"><i class="glyphicon glyphicon-search"></i><span>&nbsp;About Us</span></a></li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="register.php"><i class="glyphicon glyphicon-registration-mark"></i><span>&nbsp;Register</span></a></li>
        <li class="active"><a href="login.php"><i class="glyphicon glyphicon-user"></i><span>&nbsp;Login</span></a></li>
      </ul>
    </div><!--/.nav-collapse -->
  </div>
</div>

This is the demo. http://jsfiddle.net/5TATB/

这是演示。 http://jsfiddle.net/5TATB/

Thanks in advance!

提前致谢!

1 个解决方案

#1


1  

According to what I had saw in the console, you did not include jquery framework on jsfiddle and I am sure you did it exactly in your code.

根据我在控制台中看到的内容,你没有在jsfiddle上包含jquery框架,我相信你在代码中完全做到了。

Bootstrap中的Dropdown Navbar无法正常工作

Bootstrap was built with a jquery complement. Before you can use the bootstrap nice javascript plugins you must include jquery before bootstrap.min.js.

Bootstrap是用jquery补充构建的。在使用bootstrap nice javascript插件之前,必须在bootstrap.min.js之前包含jquery。

See documentation here!

请参阅此处的文档

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

Working demo here

在这里工作演示

#1


1  

According to what I had saw in the console, you did not include jquery framework on jsfiddle and I am sure you did it exactly in your code.

根据我在控制台中看到的内容,你没有在jsfiddle上包含jquery框架,我相信你在代码中完全做到了。

Bootstrap中的Dropdown Navbar无法正常工作

Bootstrap was built with a jquery complement. Before you can use the bootstrap nice javascript plugins you must include jquery before bootstrap.min.js.

Bootstrap是用jquery补充构建的。在使用bootstrap nice javascript插件之前,必须在bootstrap.min.js之前包含jquery。

See documentation here!

请参阅此处的文档

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

Working demo here

在这里工作演示