第二个跨度进入新的一行

时间:2015-06-26 08:59:11

标签: html twitter-bootstrap

所以我对Bootstrap span有一个奇怪的问题。

我有两个跨度的输入文本。但第二个span将进入新的界限。 这是一个例子:

<div class="col-md-6" style="width:50%;margin-bottom: 10px">        
<div class="input-group">
  <span class="input-group-addon">$</span>
  <input type="text" class="form-control" aria-label="Amount (to the nearest dollar)">
  <span class="glyphicon glyphicon-search"></span>
</div>          
</div>

JsFiddle example

如何让第二个跨度保持在同一行?

1 个答案:

答案 0 :(得分:1)

Just add the input-group-addon class to your second span.

<div class="col-md-6" style="width:50%;margin-bottom: 10px"> 
    <div class="input-group">
        <span class="input-group-addon">$</span>
        <input type="text" class="form-control" aria-label="Amount (to the nearest dollar)">
        <span class="input-group-addon glyphicon glyphicon-search"></span>
    </div>
</div>

The only problem is that the glyphicon has a top:1px style which gives you an offset of 1 pixel. Just override that in your css.

相关问题