Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap inline text box and search button

I have search input box, that I want styled with the bootstrap with the bootstrap form-control look. Problem is, I also want the search button on the same line as the search box. I thought this could be done with form-inline, but when I add class form-control to the search box, the search button gets pushed to the next line:

<div class="input-group" >
    <div class="form-inline">
      <input id="address" type="textbox" placeholder="City or Zipcode" class="form-control" >
      <input class="btn btn-sm btn-primary" type="button" value="Search" id="addressSearch">
    </div>
</div>

http://jsfiddle.net/TLEbG/

If I remove class="form-control" from the input textbox, the button is displayed in-line:

http://jsfiddle.net/ETs9M/

How can I keep the form-contol box styling, while keeping the button inline?

like image 635
dmt2989 Avatar asked Apr 01 '14 20:04

dmt2989


People also ask

How do I add a search icon inside a text box in Bootstrap?

Step by step guide for the implementation:Step 1: Include Bootstrap and jQuery CDN into the <head> tag before all other stylesheets to load our CSS. Step 2: Add <div> tag in the HTML body with class container. Step 3: Now add any icon that you want using the below syntax, where the name is the name of glyphicon.

How do you put a button next to a textbox?

You could use flexbox. Put display:flex; on the containing div. Maybe you could use <table> , put textbox in one cell, button in the other. And set the width of the table 100%.

How do I search in Bootstrap?

You can make your input in search component focusable by pressing ctrl + alt shortcut. You are able to easily change combinations of shortcuts by modifing keys array in JS code.

How do I move the search bar to the right side in Bootstrap?

Bootstrap allows us to align elements by using the utility class float. As we want to align the button to the right side of the text box, we have to use the float-right class. Example: html.


1 Answers

Try using input groups: https://getbootstrap.com/docs/4.4/components/input-group/ this puts the button next to the textfield and makes it one component

like image 194
Cam Tullos Avatar answered Dec 11 '22 07:12

Cam Tullos