2016-12-07 47 views
1

使用Bootstrap,我是否需要將「form-group」類包裝在每個單獨的輸入中,還是可以將它包裝在整個輸入集合中?完全忽略它,因爲我的表單已經和沒有它一起工作)?twitter bootstrap:是窗體內部所需的窗體組類

根據它好像它使用簡單,它們的目的(「最佳間距」),並且不需要進行正確收集用戶輸入的引導文檔:http://getbootstrap.com/css/#forms

下面的代碼看起來,如果我換了樣form-group class圍繞一系列輸入:

<form class="form-horizontal"> 
    <div class="form-group"> 
     <div class="col-sm-6"> 
      <label for="one" class="col-sm-2 control-label">Input One:</label> 
      <div class="col-sm-10"> 
       <input type="number" step="any" class="form-control" id="one"> 
      </div> 
      <label for="two" class="col-sm-2 control-label">Input Two:</label> 
      <div class="col-sm-10"> 
       <input type="number" step="any" class="form-control" id="two"> 
      </div> 
     </div> 
    </div> 
</form> 

我也想知道建議的做法是否建議使用它。

回答

0

bootstrap的好處是,它取決於你。你是正確的,它只用於造型的目的。使用form-control類只增加了以下樣式元素:

.form-control { 
    display: block; 
    width: 100%; 
    height: 34px; 
    padding: 6px 12px; 
    font-size: 14px; 
    line-height: 1.42857143; 
    color: #555; 
    background-color: #fff; 
    background-image: none; 
    border: 1px solid #ccc; 
    border-radius: 4px; 
    -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075); 
    box-shadow: inset 0 1px 1px rgba(0,0,0,.075); 
    -webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s; 
    -o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s; 
    transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s; 
} 

所有它確實是幫助你獲得更標準的尋找表格。我的建議是以一致的方式使用它,例如,具有.form-control課程的x組元素,或者單獨使用它們,但是除非絕對必要,否則不要砍斷和改變。

希望這會有所幫助!

+0

我在詢問'form-group'類而不是'form-control'類。儘管如此,您已經回答了我的問題:這些課程嚴格按照造型設計,並且讓元素看起來不錯 –