FOR BOOTSTRAP 3.X:
Bootstrap now has the following style for table cells:
.table tbody > tr > td{
vertical-align: top;
}
The way to go is to add your own class, adding more specificity to the previous selector:
.table tbody > tr > td.vert-aligned {
vertical-align: middle;
}
And then add the class to your td
s:
<tr>
<td class="vert-aligned"></td>
...
</tr>
FOR BOOTSTRAP 2.X
There is no way to do this with Bootstrap.
When used in table cells, vertical-align does what most people expect it to, which is to mimic the (old, deprecated) valign attribute. In a modern, standards-compliant browser, the following three code snippets do the same thing:
<td valign="middle"> <!-- but you shouldn't ever use valign --> </td>
<td style="vertical-align:middle"> ... </td>
<div style="display:table-cell; vertical-align:middle"> ... </div>
Check your fiddle updated
Further
Also, you can't refer to the td
class using .vert
because Bootstrap already has this class:
.table td {
padding: 8px;
line-height: 20px;
text-align: left;
vertical-align: top; // The problem!
border-top: 1px solid #dddddd;
}
And is overloading the vertical-align: middle
in '.vert' class, so you have to define this class as td.vert
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…