本文介绍了Twitter Bootstrap,Nav-bar,下拉不能正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一个自适应导航栏与引导。但是,下拉菜单无法正常工作。

I am trying to make a responsive nav-bar with bootstrap. However, the drop down menu is not working properly.

我想在品牌名称下方放置一个不与之相伴的下拉菜单。

I want to have the drop down under the brand name not along with it.

这是我的代码:

<html>
<head>
<meta name="viewport" content="width=device-width, intial-scale=1.0">
<link href="css/bootstrap.min.css" type="text/css" rel="stylesheet">
</head>
<body>
<div class="navbar navbar-inverse navbar-static-top">
    <div class="container">
        <a href="#" class="navbar-brand">ACUPRESSURE</a>

        <button type="button" class = "navbar-toggle" data-toggle ="collapse" data-target = ".navHeaderCollapse">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        </button>

        <div class = "collapse navbar-collapse navHeaderCollapse">

            <ul class="nav navbar-nav navbar-right">
                <li><a href ="#">Home</a></li>
                <li><a href ="#">Home</a></li>
                <li><a href ="#">Home</a></li>
                <li><a href ="#">Home</a></li>
                <li><a href ="#">Home</a></li>
            </ul>
        </div>          
    </div>
</div>
<script src= "http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script>
<script src= "js/bootstrap.js"></script>
</body>
</html>


推荐答案

环绕 navbar-toggle navbar-brand 的类的navbar-header 请参阅。

You're missing the navbar-header class that surrounds navbar-toggle and navbar-brand. See the Docs.

工作示例。

Working Example.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="navbar navbar-inverse navbar-static-top">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navHeaderCollapse"> <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>

      </button><a href="#" class="navbar-brand">ACUPRESSURE</a>

    </div>
    <div class="collapse navbar-collapse navHeaderCollapse">
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#">Home</a>

        </li>
        <li><a href="#">Home</a>

        </li>
        <li><a href="#">Home</a>

        </li>
        <li><a href="#">Home</a>

        </li>
        <li><a href="#">Home</a>

        </li>
      </ul>
    </div>
  </div>
</div>

这篇关于Twitter Bootstrap,Nav-bar,下拉不能正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 07:09