To sum it up, there are few approaches to align content vertically in container. These are main approaches (if you now some completely different way to do it, it would be ve
If I need IE7 support, I tend to go for the "display: inline-block
with an extra element" method. This does work in IE7 with a small change, here's an example.
If I don't need IE7 support, I usually use the display: table-cell
method.
Sometimes, I can't use the display: table-cell
method, typically when I need to use absolutely position something at the bottom of the element with display: table-cell
. position: relative
doesn't work on table cells, at least in Firefox. In those cases, I use the display: inline-block
method, except that the "extra element" is inserted via :before
, which keeps the HTML clean.