gpt4 book ai didi

jquery - 如何将两个导航栏折叠内容放在同一行

转载 作者:太空宇宙 更新时间:2023-11-04 03:43:03 25 4
gpt4 key购买 nike

我必须导航栏折叠内容。我只想在同一行(内联)显示这些内容。

<header class="navbar navbar-fixed-top" role="navigation">
<div class="navbar-inner">
<div class="container">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-rt-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-mid-collapse">
<span class="glyphicon glyphicon-search"></span>
</button>
<a class="navbar-brand" rel="home" href="">My Project</a>
<div class="collapse navbar-collapse" id="navbar-mid-collapse">
<form class="navbar-form form-inline" role="search" method="get" id="search-form" name="search-form">
<div class="input-group">
<input type="text" class="form-control">

<div class="input-group-btn">
<button type="submit" class="btn btn-success"><span
class="glyphicon glyphicon-search"></span></button>
</div>
</div>
</form>
</div>
<div class="collapse navbar-collapse" id="navbar-rt-collapse">
<ul class="nav navbar-nav">
<li><a data-toggle="modal" href="#" data-target="#">Login</a></li>
<li><a data-toggle="modal" href="#" data-target="#">Register</a></li>
</ul>
</div>
</div>
</div>

Output

那么,如何在同一行显示#nabar-mid-collapse 和#navbar-rt-collapse?谢谢

最佳答案

您需要一些额外的 CSS 和对标记的调整以获得您想要的结果:

CSS:

body {
padding-top: 50px;
}
.navbar-inverse .navbar-toggle {
color: #fff;
width: 44px;
height: 36px;
}
@media (max-width: 767px) {
.navbar-inverse .navbar-collapse .navbar-form{
margin: 0;
border: 0 none;
}
.navbar-form .form-group {
float: left;
min-width: 80%;
margin-right: 10px;
}
}
@media (min-width: 768px) {
.navbar-collapse.collapse {
display: inline-block!important;
float: left;
}
}

HTML:

<header class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle pull-right" data-toggle="collapse" data-target="#navbar-rt-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<button type="button" class="navbar-toggle pull-right" data-toggle="collapse" data-target="#navbar-mid-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="glyphicon glyphicon-search"></span>
</button>
<a class="navbar-brand" rel="home" href="">My Project</a>
</div>
<div class="navbar-collapse collapse" id="navbar-mid-collapse">
<form class="navbar-form" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-search"></span></button>
</form>
</div>
<div class="navbar-collapse collapse" id="navbar-rt-collapse">
<ul class="nav navbar-nav">
<li><a data-toggle="modal" href="#" data-target="#">Login</a></li>
<li><a data-toggle="modal" href="#" data-target="#">Register</a></li>
</ul>
</div>
</div>
</header>

Bootply Demo

关于jquery - 如何将两个导航栏折叠内容放在同一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24594560/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com