2015-10-19 55 views
1

使用Bootstrap,是否有一種優雅的方式可以讓每個行中的表單的所有標籤都具有相同的高度,以便輸入的底部彼此對齊?所有具有相同高度的標籤,每行

請看看這個JSFiddle

我想那是什麼第二個標籤的高度「相同的高度離開」左邊是相同的高度標籤。或者,如果右側的輸入與另一個輸入的底部對齊,那也是可行的。

回答

4

updated fiddle

<div class="container-fluid"> 
    <div class="row"> 
     <div class="col-xs-6"> 
      <label class="control-label" for="total_contribution_months">A very large and long label for an input</label> 
     </div> 
     <div class="col-xs-6"> 
      <label class="control-label" for="age">Same height as left</label> 
     </div> 
    </div> 
    <div class="row"> 
     <div class="col-xs-6"> 
      <input id="total_contribution_months" class="form-control" type="text"> 
     </div> 
     <div class="col-xs-6"> 
      <input id="age" class="form-control"> 
     </div> 
    </div>   
</div> 
+0

哦,我明白了。謝謝。 但是在將標籤放在一行中以及在其他行中放置相應的控件時是否存在任何缺陷? – pedropais

+2

哦,這打破了任何響應,因爲現在一個標籤跟着另一個:/ – pedropais

+0

我認爲沒有缺點,導致標籤和輸入與forother和id屬性鏈接。 解釋你的反應意義,似乎evrthg確定:) – userlond

0

我們通常不會通過把所有標籤成一排犧牲響應。

解決方法:爲您的標籤添加一個任意高度,然後將所有標籤文本推到底部。

label { 
    height: 40px; 
    vertical-align: bottom; 
    display: table-cell; 
    padding-bottom: 5px; 
} 

普萊舍注vertical-align是有效的,只有當display: table-cell;

JSFiddle

相關問題