There are two options for dynamic vertical centering.
- You use Javascript to get the height of the element and then do some math to set the top of the element to half of the height of the parent minus half of the element.
- You use
display: table
and percentages to get it to align properly, as shown by this article.
I've also had some luck with line-height
and vertical-align
, but that's not dynamic.