Put a font-awesome icon inside an input tag
Bootstrap 3
Checkout the Bootstrap examples in the Font Awesome documentation:
<div class="input-group margin-bottom-sm">
<span class="input-group-addon"><i class="fa fa-envelope-o fa-fw"></i></span>
<input class="form-control" type="text" placeholder="Email address">
</div>
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-key fa-fw"></i></span>
<input class="form-control" type="password" placeholder="Password">
</div>
It should work out of the box, so if you still have height differences, check that there is not other CSS stuff that override your input-group-addon
height
Working JSFiddle: https://jsfiddle.net/vs0wpy80
Bootstrap 4
Bootstrap 4 introduced some new classes for input groups, we need to use input-group-prepend
and input-group-append
:
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-envelope-o fa-fw"></i></span>
</div>
<input class="form-control" type="text" placeholder="Email address">
</div>
<div class="input-group mb-3">
<input class="form-control" type="text" placeholder="Email address">
<div class="input-group-append">
<span class="input-group-text"><i class="fa fa-envelope-o fa-fw"></i></span>
</div>
</div>
Working JSFiddle: https://jsfiddle.net/8do9v4dp/5/
input.form-control{
margin-top: 0;
}
In my case it helps