That's how to center absolutely positioned elements.
I was thinking though, you also have:
That might take precedence. Best to get rid of that, since we are trying to override it anyway.
In any case, what I've told you is true. Try this stand alone example page that illustrates the effect:
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
#div1 {
position: absolute;
height: 219px;
width: 252px;
color: white;
background-color: blue;
left: 50%;
margin-left: -126px;
top: 50%;
margin-top: -110px;
}
#div1 div {
padding: 10px;
}
</style>
</head>
<body>
<div id="div1">
<div>
Greetings from Asbury Park!
</div>
</div>
</body>
</html>
Or navigate to this demo:
http://home.comcast.net/~jscheuer1/side/center_div/
The fact that it's not working out for you on your page probably indicates that something else is going on there, perhaps a container with relative or absolute position, or a conflict of styles as mentioned at the beginning of this post.
It could of course also be something else, or something else in combination with one or more of the possibilities I've already mentioned.
Bookmarks