<DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>

R之窝 - 在线调试代码</title>
<style type="text/css">
* {font:normal 12px/150% "宋体",Arial;padding:0;margin:0;}
body {margin:0px;}
.box1 {position:absolute;width:500px;height:200px;left:50%;top:50%;margin-top:-100px;margin-left:-250px;background-color:#CCCCFF;}
</style>
</head>
<body>
<div class="box1">
</div>
</body>
</html>
QUOTE:
/*
IE里用的居中方法是text-align:center;[对象内容文本居中],由于IE里不分文本与BOX[容器],所以该属性把BOX[容器]也给居中了,DIV也属于容器。
但是在FF里,就遵从标准了,所以该属性并不能让BOX[容器]居中,推荐一个使BOX[容器]居中的方法:
<body style="text-align:center;">
<div style="margin:0 auto;">margin[外补丁]上下补丁值为0,左右补丁值为自适应。也就是说左右是自动适应浏览器的,所以该对象自身居中了。不过该方法对IE又无效,所以还是要给BODY加上texdt-align:center;。
这也是最常用的方法。</div>
</body>
*/