Navbar Bootstrap允许一个项目在汉堡包glyphicon之外

时间:2016-04-06 20:57:18

标签: css twitter-bootstrap navbar

我已经实现了一段代码。当浏览器窗口的大小(宽度方向)减小时,菜单选项卡会进入可点击的汉堡字形。

我想维护此功能,但在浏览器缩小尺寸时在glyphicon外添加一个导航选项卡。

使用bootstrap怎么可能?我试图添加另一个

<div class="navbar"> <ul class="nav navbar-nav"> <li> </li> </ul> </div>

在一个ID&#39; d&#34; mainNavBar&#34;之前然而,这导致格式不佳,我认为可以通过将两个div彼此相邻浮动来修复,但我无法解决这些问题。

以下是我的代码。

&#13;
&#13;
<!DOCTYPE HTML>

<html>

<head>

  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/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.5/js/bootstrap.min.js"></script>

</head>

<body>

  <!-- Navigation bar -->
  <nav class="navbar navbar-custom navbar-fixed-top">

    <div class="container-fluid">

      <!-- Logo -->

      <div class="navbar-header">

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

          <span class="glyphicon glyphicon glyphicon-menu-hamburger"></span>

        </button>

        <a href="../homepage.html" class="navbar-brand"> Markets</a>

      </div>

      <!-- menu items -->

      <div class="collapse navbar-collapse" id="mainNavBar">

        <ul class="nav navbar-nav navbar-right">

          <li> <a href="../aboutus.html">About Us</a> 
          </li>
          <li> <a href="../news.html">News</a> 
          </li>
          <li> <a href="../analysis.html">Analysis</a> 
          </li>
          <li> <a href="../randomarticle.html">Random Article</a> 
          </li>
          <li> <a href="../contactus.html">Contact Us</a>

          </li>

      </div>
  </nav>
  <!-- End Navigation Bar -->

</body>

</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:2)

Bootply http://www.bootply.com/Vky1AGlU5F

<强> CSS

.still_on_view{
    float: right;
}

<强> HTML

  <nav class="navbar navbar-custom navbar-fixed-top">

    <div class="container-fluid">

      <!-- Logo -->

      <div class="navbar-header">

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

          <span class="glyphicon glyphicon glyphicon-menu-hamburger"></span>

        </button>

        <ul class="still_on_view nav navbar-nav">

          <li> <a href="../aboutus.html">About Usb2</a> 
          </ul>
        <a href="../homepage.html" class="navbar-brand"> Markets</a>

      </div>
      <div>

      </div>

      <!-- menu items -->

      <div class="collapse navbar-collapse" id="mainNavBar">

        <ul class="nav navbar-nav navbar-right">

          <li> <a href="../aboutus.html">About Us</a> 
          </li>
          <li> <a href="../news.html">News</a> 
          </li>
          <li> <a href="../analysis.html">Analysis</a> 
          </li>
          <li> <a href="../randomarticle.html">Random Article</a> 
          </li>
          <li> <a href="../contactus.html">Contact Us</a>

          </li>

      </div>
  </nav>