2014-12-27 85 views
0

我想減少表單輸入元素之間的差距。如何減少自舉輸入元素之間的差距

DEMO

HTML:

<form class="form-horizontal width-500 center-block theme-font" role="form"> 
    <div class="form-group form-group-sm"> 

     <label for="name" class="control-label col-xs-4">Guardian Name</label> 
     <div class="col-xs-3 form-inline"> 
      <select class="form-control" id="village" required="required"> 
       <option>S/O</option> 
       <option>D/O</option> 
       <option>W/O</option> 
       <option>C/O</option> 
      </select> 
      <div class="required-icon"> 
       <div class="text">*</div> 
      </div> 
     </div> 

     <div class="col-sm-5 form-inline float-left"> 
      <input class="form-control" required="required" id="name" placeholder="Guardian Name" type="text"> 
      <div class="required-icon"> 
       <div class="text">*</div> 
      </div> 
     </div> 

    </div> 
</form> 
+1

最簡單的方法是從下拉菜單中刪除所需的圖標,並刪除兩個浮動左側。然後刪除列,因爲他們給出一個寬度。 –

回答

1

如果你想獲得哈克與它(將要在以後的其他輸入類型添加),您可以添加此的CSS:

select, input { 
    min-width: 100%; /* Force element to take up the whole column width */ 
} 

.required-icon { 
    position: absolute; /* Allow icon to stack within the 100% min-width input fields */ 
    right: 0; /* Force it to the right side of the block */ 
    top: 4px; /* Quick position fix */ 
} 

.tooltip { 
    left: -70px !important; /* Override and bring the tooltip behind the input fields */ 
} 

希望這會有所幫助。喜歡上面提到的,你將不得不將額外的輸入字段(textarea等)添加到追加「min-width:100%」屬性的選擇器列表中。快樂的黑客攻擊。

+0

代碼更新http://www.bootply.com/la8RLL9IUn請你能告訴我如何讓Guardian名稱輸入字段與表單中的其他字段對齊。?????? –

+0

@ user2217267 '#village {width:40%; margin-right:18px;}' 將此行添加到您的CSS文檔中以實現此目的。這是非常冒險的,就像我之前說過的,所以通過添加下面的代碼可以實現一個安全的賭注。 '@media(min-width:768px){ .form-inline .form-control {width:100%width; 97%; margin-bottom:5px; } }' – Ryne

相關問題