我在使用<div display='table-cell'>
時遇到兩個組件需要對齊時遇到問題。第一個組件在頂部顯示一個間隙。我希望他們被顯示,以便他們對齊。HTML/CSS display =表格行對齊
這裏的的jsfiddle:http://jsfiddle.net/66s7x5fr/
這裏的HTML:
<div class="form-group modifierColumn">
<div class="cell">
<select class="form-control input-sm btn-primary">
<option value="Broad">Broad</option>
<option value="Moderate">Moderate</option>
<option value="Single">Single</option>
</select>
</div>
<div class="cell">
<span class="input-group input-group-sm">
<span class="input-group-btn">
<button class="btn btn-primary" type="button"> <i class="fa fa-minus"></i> </button>
</span>
<input class="form-control text-justify" type="text" value="0"> </input>
<span class="input-group-btn">
<button class="btn btn-primary" type="button"> <i class="fa fa-plus"></i> </button>
</span>
</span>
</div>
</div>
這裏的CSS:
.modifierColumn .cell:not(:last-child) {
padding-right: 5px;
}
.cell {
display: table-cell;
}
可能重複[如何居中水平表單元格(http://stackoverflow.com/questions/16226625/how-to-center-horizontal-表格單元格) – davidcondrey 2014-09-04 20:22:33
垂直對齊'.cell's:http://jsfiddle.net/66s7x5fr/4/ – Moob 2014-09-04 20:24:25