Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 751
Kendall H. Avatar asked Oct 28 '16 10:10

Kendall H.


1 Answers

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>
like image 140
Anil Kumar Ram Avatar answered Nov 23 '22 05:11

Anil Kumar Ram