How do I vertically center a div that is inside a table cell?
HTML:
<tr class="rowClass">
<td class="cellClass">
<div class="divClass">Stuff</div>
</td>
</tr>
CSS:
.rowClass {
vertical-align:middle !important;
height:90px;
}
.cellClass {
vertical-align:middle !important;
height:90px;
}
.divClass {
vertical-align:middle !important;
height:90px;
}
I know the class definitions are redundant, but I've been trying lots of different things. Why isn't the solution (whatever it is) intuitive. None of the "obvious" solutions that I tried would work.
There is no need to define
height
in .divClass . write like this:Check this http://jsfiddle.net/ncrKH/
.divClass { margin-top:auto; }
HTML
CSS
Live Example
The best tutorial I have ever found regarding this question: How to vertically center stuff
With out any css itself you can do this with
valign="middle"
try this code.