2012-10-09 64 views
2

我對對齊場無標籤如何正確引導形式

<form action="#" method="post" class="well"> 
    <fieldset> 
     <div class="control-group"> 
      <label class="control-label" for="FirstName">Name</label> 
      <div class="controls row-fluid"> 
       <div class="span2 row"> 
        <input class="span12" id="FirstName" name="FirstName" placeholder="Firstname" type="text" value=""/> 
       </div> 
       <div class="span2 row"> 
        <input class="span12" id="MiddleName" name="MiddleName" placeholder="Middlename" type="text" value=""/> 
       </div> 
       <div class="span2 row"> 
        <input class="span12" id="LastName" name="LastName" placeholder="Lastname" type="text" value=""/> 
       </div> 
      </div> 
     </div> 
    </fieldset> 
</form> 

的jsfiddle:http://jsfiddle.net/bWGfb/

我要添加標籤爲姓,所以我想有一標籤,姓只。引導程序如何可能?

UPDATE: 我可以做這樣的事情:

<div class="row-fluid"> 
    <div class="span12"> 
     <div class="span4"> 
      <label>First Name</label> 
      <input type="text" class="span12" placeholder="First Name"> 
     </div> 
     <div class="span4" style="margin-top: 25px;"> 
      // field without label 
      <input type="text" class="span12" placeholder="Last Name"> 
     </div> 
     <div class="span4 "> 
      <label>First Name</label> 
      <input type="text" class="span12" placeholder="Last Name"> 
     </div> 
    </div> 
</div> 
​ 

http://jsfiddle.net/bWGfb/1/

,但它增加了額外的保證金風格。

回答

1

事情是這樣的:

<form action="#" method="post" class="well"> 
    <fieldset> 
     <div class="control-group"> 
      <div class="row-fluid"> 
       <div class="span3"> 
        <label for="FirstName">First name</label> 
        <input class="span12" id="FirstName" name="FirstName" placeholder="Firstname" type="text" value=""/> 
       </div> 
       <div class="span3"> 
        <label for="MiddleName">&nbsp;</label> 
        <input class="span12" id="MiddleName" name="MiddleName" placeholder="Middlename" type="text" value=""/> 
       </div> 
       <div class="span3"> 
        <label for="LastName">Last name</label> 
        <input class="span12" id="LastName" name="LastName" placeholder="Lastname" type="text" value=""/> 
       </div> 
      </div> 
     </div> 
    </fieldset> 
</form> 
+0

沒錯,但是如何去除中間名的標籤並保存正確的內聯對齊? – johnny

+2

可能有點不好意思,但是''label for =「MiddleName」>  '會做:P –

0

只是覆蓋bootstrap.css(線946)的label風格在自己的CSS

5px下邊距,只需將其設置爲你所需要的,但TBH有點間距是好的;)