Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 3 has-feedback icon alignment with field sizing doesn't seem to work

I am trying to use the has-feedback form class to add an icon on a form field, however with input field sizing, the icon is shown out of bounds, below is jsfiddle of the problem:

jsfiddle

<div class="container">


 <div class="row col-md-6">
        <form name="form">
            <div class="form-group has-feedback">
                <label class="control-label" for="userName">Username (BROKEN)</label>
                <div class="row">
                    <div class="col-sm-5">
                         <input type="text"required class="form-control" />
                         <span class="glyphicon glyphicon-ok form-control-feedback"></span>
                    </div>
                </div>
            </div>
            <div class="form-group has-feedback">
                <label class="control-label" for="userName">Username (WORKS)</label>
                <input type="text"required class="form-control" />
                <span class="glyphicon glyphicon-ok form-control-feedback"></span>
            </div>
       </form>
   </div>
</div>

It only works when the field has default sizing which is 100% of the containing form.

Any ideas how to control field size and allow to display icon correctly?

like image 377
Val Avatar asked Feb 16 '14 05:02

Val


1 Answers

Had the same problem yesterday.

Solved it by adding this css. Just edit the top and right positions to suit your design.

.has-feedback .form-control-feedback {
    position: absolute;
    top: 3px;
    right: 15px;
    display: block;
    width: 34px;
    height: 34px;
    line-height: 34px;
    text-align: center;
}
like image 173
Julien Avatar answered Oct 20 '22 20:10

Julien