Kendall H.
Kendall H.

Reputation: 461

Search box with button (Bootstrap 3)

I want to create a search box with a button on it's side, like the this:

enter image description here

But just on the right side of the page. So I put pull-right and this is how my code like:

<form action="/hms/accommodations" method="GET">            
<div class="input-group pull-right">
   <input type="text" class="form-control" placeholder="Search" id="txtSearch"/>
   <div class="input-group-btn pull-right">
        <button class="btn btn-primary" type="submit">
        <span class="glyphicon glyphicon-search"></span>
        </button>
   </div>
   </div>
</form>

and when I tried to run it, this is how it looks like:

enter image description here

Why is does the alignment like that? I hope someone can help me. Thank you.

Upvotes: 10

Views: 56898

Answers (3)

katy
katy

Reputation: 11

<div class="col-md-5">
                        <div class="search-box">
                         <input type="search" class="form-control ds-input" id="search-input"
                                placeholder="Search..." autocomplete="off" spellcheck="false" role="combobox"
                                aria-autocomplete="list" aria-expanded="false"
                                aria-owns="algolia-autocomplete-listbox-0"
                                style="position: relative; vertical-align: middle;" dir="auto">
                        </div>
                    </div>

Upvotes: 0

Anil Kumar Ram
Anil Kumar Ram

Reputation: 1221

Remove pull-right class from <div class="input-group-btn pull-right">

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<form action="/hms/accommodations" method="GET"> 
  <div class="row">
    <div class="col-xs-6 col-md-4">
      <div class="input-group">
        <input type="text" class="form-control" placeholder="Search" id="txtSearch"/>
        <div class="input-group-btn">
          <button class="btn btn-primary" type="submit">
            <span class="glyphicon glyphicon-search"></span>
          </button>
        </div>
      </div>
    </div>
  </div>
</form>

Upvotes: 27

surender
surender

Reputation: 24

Try to add ( float:left ) to form-control. i hope it will works.

Upvotes: -1

Related Questions