I am working in Bootstrap 3 and am trying to get a calendar icon inside the right hand side of the input box.
My html looks like this:
<div class="col-md-12">
<div class='right-inner-addon col-md-2 date datepicker'
data-date-format="yyyy-mm-dd">
<input name='name' value="" type="text" class="form-control date-picker"
data-date-format="yyyy-mm-dd"/>
<i class="fa fa-calendar"></i>
</div>
</div>
I have tried position: absolute
like this:
.right-inner-addon i {
position: absolute;
right: 5px;
top: 10px;
pointer-events: none;
font-size: 1.5em;
}
.right-inner-addon {
position: relative;
}
But when I do it will look great in one spot, but will not be positioned correctly in another instance.
I have also tried to see if I could use text-indent
to see if this would work throughout, but it had the same effect.
.right-inner-addon i,
.form-group .right-inner-addon i {
display: inline-block;
z-index: 3;
text-indent: -15px;
font-size: 1.3em;
}
Using bootstrap's native validation states is probably preferable to writing custom CSS here.
And I'm pretty sure that I'm the one who came up with the CSS in question.
Just use
.has-feedback
on your form-group and.form-control-feedback
on your icon:Demo in jsFiddle
You can use
input-group add-on
with ainput-group-btn
.With a little CSS to hide the button border:
Demo: http://bootply.com/128059
Check this fiddle, adapted from this answer
The difference being that in your case the
<i>
was placed after<input>
. Swapping them makes it work. That's why the positioning was creating a mess as opposed to the cited answer.In above answers, Input click works but click on i tag is not working. so I have added my code in answer of @KyleMit
I changed css little bit for my UI. You also can change it.