当前,我的左侧有徽标,其余的东西在右边。我唯一的问题是我希望搜索字段就在右边的徽标旁边。
我尝试将其插入同一div,但最终会在其下方插入。任何帮助将不胜感激!
html:
<div class="top-nav">
<nav class="navbar navbar-inverse" role="navigation">
<div class="navbar-header">
<a class="navbar-brand" href="#">
<img src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" class="logo" />
</a>
</div>
<div class="collapse navbar-collapse ">
<ul class="nav navbar-nav navbar-right">
<li id="search">
<input class="search-input" placeholder="Search" type="text" />
<a href="#">
<i class="glyphicon glyphicon-search"></i>
</a>
</li>
<li>
<div class="register-login"><a href="#">Login</a> <a href="#">Sign Up</a></div>
</li>
</ul>
</div>
</nav>
</div>
JSFIDDLE DEMO
我希望您更换这样的代码:
<div class="top-nav">
<nav class="navbar navbar-inverse" role="navigation">
<div class="navbar-header">
<a class="navbar-brand" href="#">
<img src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" class="logo" />
</a>
<div class="nav navbar-nav navbar-collapse">
<input class="search-input" placeholder="Search" type="text" />
<a href="#">
<i class="glyphicon glyphicon-search"></i>
</a>
</div>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-right">
<li>
<div class="register-login"><a href="#">Login</a> <a href="#">Sign Up</a></div>
</li>
</ul>
</div>
</nav>
</div>
我从 <li>
中添加了徽标旁边的.nav
。
如果搜索图标脱离区域,请使用:
#search {
display: inline-block;
position: relative;
}