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
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.
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.
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>
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(); });
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