I have been Googling this and find many entries on it, most of which use table-cell like this:
http://www.vdotmedia.com/blog/vertically-center-content-with-css/
They work fine, but why I change the DOCTYPE to XHTML1.1, which I need for an EPUB page:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
It no longer works. Am I out of luck? I have blocks of text that vary in length that I would like to vertically center on a page in an epub reader such as iBooks (which are based on WebKit -- I do not need to worry about other browsers).
There's another trick you can try.
If you have this structure:
<div class="container">
<div class="text">
Some text you need aligned vertically
</div>
</div>
On the CSS you'd have:
.container {
height: 50px;
position: relative;
}
.text {
position: absolute;
top: 50%;
}
You can give that a go if you'd like. Change the height to whatever you need it to be of course.