Place search form on the right of the navbar

Asked

Viewed 2,004 times

0

I’m using Bootstrap and put a search form inside a simple navbar.

The problem is that I can’t get the form away from the title, I’d like it to be aligned to the right of the navbar.

This is the HTML:

  <div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>

              <div class="navbar-brand"> TITULO </div>




            </div>
            <div class="navbar-collapse collapse">
                
               
                <div class="col-sm-4 col-md-4">
                    <form class="navbar-form" role="search" method="get" id="search-form" name="search-form">
                        <div class="input-group">
                            <input type="text" class="form-control" placeholder="Find in title or description" id="query" name="query" value="">
                            <div class="input-group-btn">
                                <button type="submit" value="Search" class="btn btn-default"><span class="glyphicon glyphicon-search"></span></button>
                            </div>
                        </div>

                    </form>
                </div>
            </div>
        </div>
    </div>

  

I put it on Bootply for ease:

http://www.bootply.com/8LqYRTJOyq

1 answer

4


For this use the class navbar-right:

<div class="col-sm-4 col-md-4 navbar-right">

  • Perfect, thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.