Bootstrap adds icon icon to the input box

<form class="form-horizontal">
    <div class="form-group has-feedback">
        <div class="username">
            <span class="fa fa-user-circle-o fa-2x form-control-feedback"></span>
            <input type="text" class="form-control" id="inputPassword" placeholder="用户名">
        </div>
    </div>
    <div class="form-group pwd-top has-feedback">
        <div class="password">
            <span class="fa fa-unlock-alt fa-2x form-control-feedback"></span>
                <input type="password" class="form-control" id="inputPassword" placeholder="密码">
            </div>
    </div>
    <div class="form-group">
                        
        <div class="checkbox  col-sm-4 col-md-4 col-lg-4">
            <label>
                    <input type="checkbox"> 记住密码
                </label>    
            </div>
        <label for="" class="col-sm-4 col-md-4 col-lg-4 control-label forget-pass"><a href="">忘记密码</a></label>  
        <label for="" class="col-sm-4 col-md-4 col-lg-4 control-label register"><a href="">注册</a></label>
    </div>
    <div class="form-group">
        <button class="btn btn-login" type="submit">&nbsp;</button>
    </div>
</form>

actual effect

Modify the css style so that the icon icon can be vertically centered, and then
line-height below the left: 50px, because my input box is 50px high

Then the right left: 20px If you don't give it, the icon icon will be aligned to the right

/*padding-left:60px   因为图标是有一个宽度,然后图标有一个left:20px   图标的宽度34px, 估计一下  设置差不多60px, 刚好让文字不被图标遮挡*/
.form-center .username input,.form-center .password input{
    height: 50px;
    padding-left: 60px;
}


.form-control-feedback {
    line-height: 50px;
    left: 20px;
} 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325265936&siteId=291194637