bootstrap - 为span添加标签

时间:2016-04-12 09:41:49

标签: css twitter-bootstrap

我有以下标记

<form role="form">                      
   <div class="input-group">
    <label for="accountSpan">Account name</label>
                        <span class="input-group-addon" id="accountSpan">something</span>
                        <input type="text" class="form-control" placeholder="account name" aria-describedby="basic-addon1" id="accountInput" >
                    </div>                                              
                    <div class="form-group">                             
                        <label for="exampleInputPassword1">Password</label>                         
                        <input type="password" class="form-control" id="exampleInputPassword1" />                       
                    </div>
    </form>

导致

enter image description here

如何让它像密码一样对齐?

3 个答案:

答案 0 :(得分:1)

请尝试以下操作: Demo

如果您使用form-groupinput-group一样使用密码,则可以获得预期的输出。

<div class="form-group">

    <label for="accountSpan">Account name</label>
    <div class="input-group">
      <span class="input-group-addon" id="accountSpan">something</span>
      <input type="text" class="form-control" placeholder="account name" aria-describedby="basic-addon1" id="accountInput">

    </div>
  </div>

答案 1 :(得分:0)

 @import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');

<form role="form"> 
<div class="input-group"> 
  <label for="accountSpan">Account name</label> 
  <span class="input-group-addon" id="accountSpan">something</span>
  <input type="text" class="form-control" placeholder="account name" 
  aria-describedby="basic-addon1" id="accountInput" > 
</div> 
<div class="form-group"> 
  <label for="exampleInputPassword1">Password</label> 
  <input type="password" class="form-control" id="exampleInputPassword1" /> 
</div> 

答案 2 :(得分:0)

您的答案jsFiddle

<form role="form">      
       <div class="form-group">   
            <label for="accountSpan">Account name</label>
                <div class="input-group">
                    <span class="input-group-addon" id="accountSpan">something</span>
                    <input type="text" class="form-control" placeholder="account name" aria-describedby="basic-addon1" id="accountInput" >
                </div>   
        </div>
        <div class="form-group">                             
            <label for="exampleInputPassword1">Password</label>                         
            <input type="password" class="form-control" id="exampleInputPassword1" />                       
        </div>
    </form>