我有一个使用bootstrap定义的导航栏,如下所示:
<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>
只有在桌面模式下使用它才能看起来不错,但在响应式布局中它会破坏 我想在导航栏中隐藏第二个栏,一个点击触发器时会激活的搜索栏,如搜索按钮
有人可以通过这样的导航栏跟我说话吗? 我尝试过这样的事情:
<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>
但是,第二个栏被第一个导航栏隐藏..
任何想法?
答案 0 :(得分:3)
由于您的第一个导航栏获得.navbar-fixed-top
,您可以在CSS代码中设置body { padding-top: 70px; }
以防止重叠,另请参阅http://getbootstrap.com/components/#navbar-fixed-top:
固定的导航栏将覆盖您的其他内容,除非您添加 填充到顶部。尝试自己的价值观或使用我们的 下面的片段。提示:默认情况下,导航栏高50像素。
我还发现您的搜索框(包含在input-group clearfix
内)没有float: left
(用于更大的屏幕宽度),这会将您的第一个导航栏分成两行。
在其他情况下,导航栏也会分为两行:Disable Bootstrap 3 navbar going 2 rows in medium viewport size
最后你还应该阅读:Multiple navbars on the same page with Twitter's Bootstrap 3