如何将glyphicon置于bootstrap形式?

时间:2015-07-07 17:19:37

标签: forms twitter-bootstrap twitter-bootstrap-3

我有一个bootstrap表单,想在SELECT字段之前添加一个glyphicon。 然而,它有点间断。

<form role="form" id="registration-form" onsubmit="return onSubmitContinueButton()">

    <div class="row"> 
        <div class="form-group col-md-6">           
            <label class="sr-only" for="xxx"></label>   
            <span class="glyphicon glyphicon-name"></span> <!--  <-- there is a breakline after this.... why?-->            
            <select class="form-control" name="aaa">                
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>                
            </select>
        </div>

        <div class="form-group col-md-6">           
            <label class="sr-only" for="xxx"></label>           
            <span class="glyphicon glyphicon-name"></span> <!--  <-- there is a breakline after this.... why?-->            
            <select class="form-control" name="aaa">                
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>                
            </select>
        </div>      
    </div>  
</form>

我希望glyphicon只是在选择字段附近而不是在它上面。 我该如何解决? 感谢

1 个答案:

答案 0 :(得分:1)

如果要在选择字段前添加图标,请将其设为像这样的输入组

<div class="input-group">
   <span class="input-group-addon" id="basic-addon1"><span class="glyphicon glyphicon-plus"></span></span>
   <select class="form-control" name="aaa">                
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>                
        </select>
</div>

有关详情,请点击此处:Bootstrap input groups