I'm using Twitter Bootstrap 3.x and I've got a table where a cell has rowspan="2". Here is the table row:
<tr>
<td rowspan="2" class="critical">
<a href="#"><span class="glyphicon glyphicon-check white"></span></a>
</td>
<td colspan="2" class="col-xs-8 col-md-10">
<b><a href="#">Title</a></b>
</td>
</tr>
<tr>
<td class="col-xs-8 col-md-10">
<em><small>12/07/2014</small></em> - <a><span class="glyphicon glyphicon-paperclip"></span></a></small>
</td>
<td class="col-xs-4 col-md-2">
<em><small class="pull-right"><a href="#" class="black">Some name</a></small></em>
</td>
</tr>
I've been looking trough StackOverflow for these solutions:
I've tried everything, and looking at Chrome dev console, everytime I add line-height or vertical-align: middle, it appears stroked and isn't applied. Tried also with !important but didnt work either.
I'd like to know if there is something preventing the rowspan cell to be aligned in middle, if it's due to rowspan (which is the most probable issue since the example's people have provide in JSFiddle vertical-align: middle works like a charm).
If there is any extra data needed Ill update the thread. Thanks in advance!
1 — Vertical Center Using Auto Margins One way to vertically center is to use my-auto . This will center the element within it's flexbox container (The Bootstrap 4 . row is display:flex ). For example, h-100 makes the row full height, and my-auto will vertically center the col-sm-12 column.
Using the Line-Height Property In most cases, you can also center text vertically in a div by setting the line-height property with a value that is equal to the container element's height.
In Bootstrap 5, if we want to vertically align an <div> element in the middle of a containing element, we can do this by applying the class align-items-center and d-flex on the containing element of that div. Here, the d-flex class has the same effect as that of the display: flex; property in CSS. Example: HTML.
Bootstrap uses selector like (shortened):
.table>tbody>tr>td {
vertical-align: top;
}
So it has bigger priority that your single class selector (.vertical-center
). So use either more specific selector or !important
.vertical-center {
vertical-align: middle !important;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With