Vertical Align Block Elements
A tale of browser incompatibilities
Method 1 - Multiple lines of content (with fixed height)
The way to accomplish vertical centering is as follows:
- Specify the parent container as position:relative or position:absolute.
- Specify a fixed height on the child container.
- Set position:absolute and top:50% on the child container to move the top down to the middle of the parent.
- Set margin-top:-yy where yy is half the height of the child container to offset the item up.
Method 2 - Single lines of content
To use this method do the following:
- Set the line-height of the parent element to the fixed height you want.