I'm trying to position a clear button inside an input field, at the right before to the search icon, however it's not working; the "x" is displayed in front of the input field instead.
i use absolute positioning with right:0 and top:4px
You can see my example here: http://www.bootply.com/YUwdJ5Kvx6
Try this i have appended the button before and after. Comment if this is you want or not. Did i understood you correct?
A little update to get what you want:
I added
position: relative
toinput-group-btn
forposition: absolute
to work on the close button. Then just a negativeright: 36px
to move the button in the input field.I put the
close
button inside theinput-group-btn
because it was easier for me, and it automatically takes care of the vertical alignment of your button (I just added thebtn
class to thea
tag).I added
padding-left: 30px !important
to the input field to avoid user typing under thex
button. To have a symmetrical space, you would need38px
, but it looks a bit much... You can change this value at your discretion to get the result you want.Since the
a
tag is inside theinput-btn-group
with thebtn
class, you need something likea:hover { box-shadow: none ; }
to avoid uglybox-shadow
in your input when clicking on the close button.