I’m encountering issues keeping all 3 components of the Bootstrap-based navbar
in one horizontal row. This navbar has fluid width.
Question: How can we tweak the code to get all the 3 items (from left to right: a
, form
and ul
) to be arrange in one line? The form
should take 100% of the space remaining betweem the orange color a
and the Login/Signup ul
.
Bootply: http://www.bootply.com/oEkHN0DVmE
Currently
Desired
HTML
<nav class="navbar navbar-default navbar-fixed-top">
<a class="brand" href="#">
<img src="/img/logo-white.png">
</a>
<form role="form" class="form-horizontal search-form">
<!-- <i class="fa fa-search"></i> -->
<input type="text" class="form-control" placeholder="Search">
</form>
<ul class="nav navbar-nav pull-right">
<li><a href="/users/sign_in">Login</a></li>
<li><a href="/users/sign_up">Sign up</a></li>
</ul>
</nav>
CSS
.brand {
width: 170px;
height: 80px;
background-color: #fc4310;
display: inline-block
}
.search-form {
width: 100%;
height: 30px;
display: inline-block;
}
4
Answers
Very simply:
That aligns all nav child elements in a single row.
For spacing the elements on the row, see options here: Methods for Aligning Flex Items
Note that flexbox is supported by all major browsers, except IE 8 & 9. Some recent browser versions, such as Safari 8 and IE10, require vendor prefixes. For a quick way to add all the prefixes you need, post your CSS in the left panel here: Autoprefixer.
Use the gird sistem:
http://www.bootply.com/rV9ZF8sO7N
Change some css
http://www.bootply.com/YFnjNIZ7Wo
Did some changes to your code…
I hope this will help you..
refer this demo
added navigation header
and change the form little bit with css