我创建了一个导航栏,但是当我尝试调整屏幕大小时,搜索栏会在某个点下方而不是折叠。我的代码是:
//row start
<div class="row">
//navbar class with affix used in css
<nav class="navbar navbar-default" data-spy="affix" data-offset-top="150">
<div class="container-fluid">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Home</a>
</div>
<div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li><a href="#">Technology</a></li>
<li><a href="#">Sports</a></li>
<li><a href="#">Science</a></li>
<li><a href="#">Entertainment</a></li>
<li><a href="#">Science</a></li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">More <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Life</a></li>
<li><a href="#">Tours and Travels</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<form style="float:right" class="navbar-form" role="search" aria-expanded="false">
<div class="input-group add-on">
<input class="form-control" placeholder="Search" name="srch-term" id="srch-term" type="text">
<div class="input-group-btn">
<button class="btn btn-default" type="submit">
<i class="glyphicon glyphicon-search"></i>
</button>
</div>
</div>
</form>
</li>
</ul>
</div>
</div>
</div>
</div>
</nav>
</div>
答案 0 :(得分:0)
我看到了更多&#39;你在那里作为布局妥协的下拉,我只是觉得需要更多的妥协。我在小屏幕上的下拉列表中缩小了所有菜单链接。
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Home</a>
</div>
<div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav visible-sm">
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">Menu <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Technology</a></li>
<li><a href="#">Sports</a></li>
<li><a href="#">Science</a></li>
<li><a href="#">Entertainment</a></li>
<li><a href="#">Science</a></li>
<li><a href="#">Life</a></li>
<li><a href="#">Tours and Travels</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav visible-md visible-lg">
<li><a href="#">Technology</a></li>
<li><a href="#">Sports</a></li>
<li><a href="#">Science</a></li>
<li><a href="#">Entertainment</a></li>
<li><a href="#">Science</a></li>
<li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">More <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Life</a></li>
<li><a href="#">Tours and Travels</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><form style="float:right" class="navbar-form" role="search" aria-expanded="false">
<div class="input-group add-on">
<input class="form-control" placeholder="Search" name="srch-term" id="srch-term" type="text">
<div class="input-group-btn">
<button class="btn btn-default" type="submit">
<i class="glyphicon glyphicon-search"></i>
</button>
</div>
</div>
</form></li>
</ul>
</div>
</div>
</div>
</div>
</nav>