Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap button inside input-group

Tags:

How to make it so that it appears nicely after input page with same height?

<div class="input-group">         <input type="text" class="form-control"/>         <button class="input-group-addon" type="submit">             <i class="fa fa-search"></i>         </button> </div> 

Here is code http://jsfiddle.net/6mcxdjdr/ The first one is original input-group, the second one is something what I am trying to have

like image 641
Boris Kozarac Avatar asked Jul 06 '16 08:07

Boris Kozarac


People also ask

How do you put a button inside input tag?

In order to put the button inside the input field, we shall use CSS. Let us see the HTML first. Creating structure: In this section, we will create the basic structure for the input field. HTML Code: By using the HTML, we will place the input field where we will add a responsive button to clear the field.

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.


2 Answers

If you follow bootstrap's documentation:

<div class="input-group">   <input type="text" class="form-control" placeholder="Search for...">   <span class="input-group-btn">     <button class="btn btn-default" type="submit">         <i class="fa fa-search"></i>     </button>   </span> </div> 
like image 166
Stephen Zeng Avatar answered Sep 29 '22 16:09

Stephen Zeng


here is my solution, using a little CSS to position the button to the right of the input field by adding position: absolute and a z-index:

button.input-group-addon {   position: absolute;   right: -38px;   top: 0;   padding: 2px;   z-index: 999;   height: 34px;   width: 38px; } 

http://jsfiddle.net/6mcxdjdr/1/

Another idea is to manipulate the form submit with javascript, so you dont have to create your own button but submit the form by clicking on the bootstrap span. This could be done by $('.input-group-addon').click(function(){ $('#myform').submit(); });

like image 33
Luuk Skeur Avatar answered Sep 29 '22 17:09

Luuk Skeur