At the moment I have found two different methods for vertically centering a paragraph.
footer {
height: 10em;
position: absolute; left: 0; right: 0;
color: white; background-color: #333;
}
footer > p {
background-color: lightBlue;
}
footer.vcenter1 { bottom: 11em; transform-style: preserve-3d; }
footer.vcenter2 { bottom: 0; }
.vcenter1 > p {
margin: 0;
position: absolute;
top: 50%; transform: translateY(-50%);
}
.vcenter2 { white-space: nowrap; word-spacing:-.25em; }
.vcenter2:before, .vcenter2 > p { display: inline-block; vertical-align: middle; }
.vcenter2:before { content:""; height: 100%; }
.vcenter2 > p { white-space: normal; word-spacing: normal; }
<!DOCTYPE html>
<html>
<head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Test</title>
<link href="Test.css" rel="stylesheet" />
</head>
<body>
<footer class="vcenter1">
<p>
test text
some text more text and more text... and more text... and more text... and more text... and more text... and more text... and more text...
<br>line3
</p>
</footer>
<footer class="vcenter2">
<p>
test text
some text more text and more text... and more text... and more text... and more text... and more text... and more text... and more text...
<br>line3
</p>
</footer>
</body>
</html>
In Firefox and Internet Explorer both seem to behave exactly the same. However is there anything in either of these two methods which might give rise to problems in other browsers?
Obviously the vcenter1 method (transform: translateY) is less CSS code but I have never been comfortable what was essentially designed to move an object at run-time for static positioning.