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?
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.
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%.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With