I have a nabvar that contains a search field ‘navbarSearchQuery’. When the navbar collapses when the screen shrinks to a phone size I want ‘navbarSearchQuery’ to remain visible in the navbar. Is there something I can do with @media queries to keep it visible or do I have to move it outside the collapsable section in the navbar?
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<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 hidden-xs" href="/Home">Yoga</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Browse <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Popular</a>
</li>
<li><a href="#">Friends</a>
</li>
<li><a href="#">Groups</a>
</li>
<li><a href="#">Neighborhoods</a>
</li>
<li><a href="#">About <span class="sr-only">(current)</span></a>
</li>
<li><a href="#">Contact</a>
</li>
</ul>
</li>
<li>
<div class="navbar-form navbar-left">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search" id="navbarSearchQuery" name="location">
</div>
</div>
</li>
</ul>
@Html.Partial("_LoginPartial")
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
2
Answers
I can put the navbar in the header part but when I shrink the alignment is slightly off. Can this be fixed?
before and after pics. you can see the button isn't aligned correctly
You can create a form inside the
navbar-header
.