【问题标题】:How to place feedback icon next to input ALWAYS in bootstrap如何在引导程序中始终在输入旁边放置反馈图标
【发布时间】:2018-07-31 13:50:40
【问题描述】:

在设计表单时,当输入的宽度低于 100% 反馈图标时不会放在它旁边:

<div class="form-group has-success has-feedback">
    <label class="control-label col-sm-3" for="inputSuccess3">Input with success</label>
    <div class="col-sm-9">
         <input class="form-control" id="inputSuccess3" aria-describedby="inputSuccess3Status" style="width: 40%;" type="text">
         <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>                    
     </div>
</div>

如果我将样式输入到 width:40% 反馈图标位置不会改变:

Demo

即使宽度或显示宽度发生变化,我如何始终在输入旁边放置反馈图标。

谢谢

【问题讨论】:

    标签: jquery html css twitter-bootstrap twitter-bootstrap-3


    【解决方案1】:

    在表单中使用网格列时,请确保它具有form-horizontal 类。对于has-feedback 图标,必须在输入容器上设置宽度。在这种情况下,您可以使用 col-sm-5,因为它的宽度约为 41%。

    <form class="form-horizontal">
            <div class="form-group has-success has-feedback">
                <label class="control-label col-sm-3" for="inputSuccess3">Input with success</label>
                <div class="col-sm-5">
                    <input class="form-control" id="inputSuccess3" aria-describedby="inputSuccess3Status" type="text">
                    <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span>
                </div>
            </div>
        </form>
    

    Demo

    【讨论】:

    • 谢谢,但由于某种原因,我不能使用col-sm-5,我想手动设置宽度
    • 由于要手动设置宽度,最好的方法是将图标设置为输入的背景图片,而不是html中的单独标签。
    猜你喜欢
    • 1970-01-01
    • 2020-11-07
    • 1970-01-01
    • 2013-07-11
    • 1970-01-01
    • 1970-01-01
    • 2014-05-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多