1

I have a navbar defined using bootstrap like this:

        <nav class="navbar navbar-default navbar-fixed-top" role="navigation">
            <div class="navbar-inner">
                <div class="container">
                    <a class="brand pull-left" href="?route=home/dashboard"> Intranet <span class="sml_t">mx</span></a>
                    <ul id="mobile-nav" class="nav navbar-nav">
                        <li class="divider-vertical hidden-sm hidden-xs"></li>
                        <li>
                            <a href="?route=home/inquiry"><i class="icon-list-alt icon-white"></i> Inquiry</a>
                        </li>
                        <li>
                            <a href="?route=home/orders"><i class="icon-list-alt icon-white"></i> Orders</a>
                        </li>
                        <li>
                            <a href="?route=home/debts"><i class="icon-list-alt icon-white"></i> C&S Debts</a>
                        </li> 
                        <li class="<?= $payroll;?>">
                            <a href="?route=home/payroll"><i class="icon-list-alt icon-white"></i> Payroll</a>
                        </li> 
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">Settings<b class="caret"></b></a>
                            <ul class="dropdown-menu">
                                <li class="<?= $admin;?>">
                                    <a href="?route=home/users/settings/roles"><i class="icon-list-alt icon-white"></i> Roles</a>
                                </li> 
                                <li class="<?= $admin;?>">
                                    <a href="?route=home/dump"><i class="icon-list-alt icon-white"></i> Dump list</a>
                                </li>                                         
                                <li class="<?= $events;?>">
                                    <a href="?route=home/calendar"><i class="icon-list-alt icon-white"></i> Calendar schedule</a>
                                </li>                                     
                            </ul>
                        </li>                                
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">Catalog<b class="caret"></b></a>
                            <ul class="dropdown-menu">
                                <li><a href="?route=home/partners">Partners</a></li>
                                <li class="<?= $products;?>"><a href="?route=home/products">Products</a></li> 
                                <li class="<?= $categ;?>"><a href="?route=home/category">Categories</a></li>
                                <li class="divider"></li>
                                <li><a href="?route=home/offers">Offers</a></li>           
                            </ul>
                        </li>
                        <li class="divider-vertical"></li>
                    </ul>

                    <div class="input-group clearfix" style="padding-top: 5px; width: 100px;">
                        <input type="text" class="form-control" placeholder="Search..." id="query" name="query" value="" />
                        <div class="input-group-btn">
                          <button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-search"></span></button>
                        </div>
                    </div>                             

                    <ul class="nav navbar-nav user_menu pull-right">
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown"><img src="<?=DIR_MEDIA?>img/user_avatar.png" alt="" class="user_avatar"><?php echo $this->user->username;?><b class="caret"></b></a>
                            <ul class="dropdown-menu">
                                <li><a href="?route=home/user_profile">Account settings</a></li>
                                <li class="<?= $admin;?>">
                                    <a href="?route=home/settings">Sys Settings</a>
                                </li>   
                                <li class="divider"></li>  
                                <li><a href="?route=logout">Log Out</a></li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </div>
        </nav>

This will look ok only if I use it in desktop mode, but in responsive layout it will break I would like to have a second bar hidden bellow the navbar, a search bar that would be active on click of a trigger, like a Search button

Could someone talk me trough a navbar like this? I have tried something like this:

            <nav class="navbar navbar-default" role="navigation">
              <!-- Brand and toggle get grouped for better mobile display -->
              <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-2">
                  <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="#">Sub menu</a>
              </div>

              <!-- Collect the nav links, forms, and other content for toggling -->
              <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-2">
                <ul class="nav navbar-nav">
                  <li class="active">
                      <input type="text" class="form-control" placeholder="Search..." id="query1" name="query" value="" />
                  </li>

                </ul>
              </div><!-- /.navbar-collapse -->
            </nav>  

But, this second bar is hidden by the first navbar..

Any ideea?

rosuandreimihai
  • 656
  • 3
  • 16
  • 39

1 Answers1

3

Because of your first navbar got the .navbar-fixed-top you could set a body { padding-top: 70px; } in your CSS code to prevent overlapping, see also http://getbootstrap.com/components/#navbar-fixed-top:

The fixed navbar will overlay your other content, unless you add padding to the top of the . Try out your own values or use our snippet below. Tip: By default, the navbar is 50px high.

I also found that your search-box (wrapped inside input-group clearfix) does not have a float: left (for larger screen width) which breaks your first navbar into two lines. The navbar will also break into two lines in other situations: Disable Bootstrap 3 navbar going 2 rows in medium viewport size

Finally you should also read: Multiple navbars on the same page with Twitter's Bootstrap 3

Community
  • 1
  • 1
Bass Jobsen
  • 48,736
  • 16
  • 143
  • 224