Forum Moderators: not2easy

Message Too Old, No Replies

Text not centering vertically in Safari 2.0.4

safari centering text vertically

         

WebOKane

1:56 am on Sep 27, 2007 (gmt 0)

10+ Year Member



The text is centering vertically in IE 6.2 and 7 and Firefox 2.0.0.7, but in Safari testing (via the browsrcamp testing site as no access to Mac) the text aligns at top of page. Any suggestions?

Here's an example of the code/CSS:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style>
body, html {
height: 100%;}
#vertcontainer {
position: relative;
height: 100%; overflow: visible;
}
#container {
position: relative;
top: 40%;
margin-left: auto;
margin-right: auto;
text-align: center;
}
</style>
</head>
<body>

Thanks in advance for your insites.

Marshall

2:07 am on Sep 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What you are describing sounds more like vertical-align: middle, not text-align: center.

Marshall

WebOKane

3:13 am on Sep 27, 2007 (gmt 0)

10+ Year Member



Mashall - thanks for the suggestion. I've implemented it as seen in the updated code below and will test it via the browsrcamp site as soon as it comes back online and report results here.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style>
body, html {
height: 100%;}
#vertcontainer {
position: relative;
height: 100%; overflow: visible;
}
#container {
position: relative;
top: 40%;
margin-left: auto;
margin-right: auto;
text-align: center;
vertical-align: middle
}
</style>
</head>
<body>
<div id="vertcontainer">
<div id="container">

The first line of text<br><br>
The second line of text.<br><br>
The third line of text.<br>

</div>
</div>
</body>
</html>