在高分辨率下css+div碰见的body居中问题

我用的是css+div。在1024*768的分辨率是居中的,高分辨率下body居左。我需要的是高分也居中。请帮我看看我的代码那里写错了。
<link href="css/body.css" rel="stylesheet" type="text/css" />
body {margin-top: 0px;
margin-left:0px;
width: 1004px;
position: absolute; }
#Layer1 {position:absolute;
width:800px;
height:331px;
z-index:1;
left: 184px;
top: 40px;
margin-right: 0px;}
其中link里的css是:
.bg {background-image: url(../images/index_bg_02.png);
background-repeat: repeat
background-position: center center;
margin-top:0px;
margin-left:0px;
margin-right:0px;
height: 592px;
width: 1004px;}
#content{background-image:url(../images/index_content_bg_03.png);
margin-left:13px;
margin-right:14px;
height:444px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-top-style: solid;
border-right-style: solid;
border-bottom-style: solid;
border-left-style: solid;
margin-top: 58px;}
#login {font-size: 12px;
color: #666666;
float: left;
height: auto;
width: 161px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-right-style: solid;
position: relative;}
#login_logo {background-image: url(../images/index_10.png);
margin: 0px;
height: 45px;
width: 161px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-bottom-style: dashed;
position: relative;}
.login_table td {font-size: 12px;
color: #666666;
text-align: right;}
.login_table {height: auto;
width: 161px;
margin-top: 20px;
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-bottom-style: dashed;}
.denglu_table {margin-left: 2px;
margin-top: 0px;}
.login_bigpictd {border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-bottom-style: dashed;}
.regimg {margin-top: 6px;
margin-bottom: 6px;}
#logo {margin-top: 8px;
overflow: visible;
position: absolute;
margin-left: 13px;
left: 0px;
top: 0px;}
#news {left: 550px;
font-size: 12px;
margin: 0px;
top: 410px;
clip: rect(0px,auto,auto,auto);
position: absolute;
width: 400px;}
#foot {font-size: 12px;
color: #B5B1B1;
background-position: center;
left: 350px;
position: absolute;
margin-top: 530px;
text-align: center;}
#news_logo {left: 200px;
position: absolute;
top: 390px;
height: 101px;
width: 361px;
border-top-width: 3px;
border-right-width: 3px;
border-bottom-width: 3px;
border-left-width: 3px;

border-right-style: dashed;}

最简单的做法:
body中margin:0 auto;
然后,后面所有页面结构放在一个层里,把这个层设置为margin:0 auto;
温馨提示:答案为网友推荐,仅供参考
第1个回答  2008-09-24
div+css建议使用盒模型来做
<html>
<head>
<title>
</title>
<style>
body { margin:0; padding:0; text-align:center;}
.box { width:1024px; margin:auto;}
/*……………………*/
</style>
</head>
<body>
<div class="box">
这里面写主要内容
</div>
</body>
</html>

还有就是样式可以简写的
比如
border-top-width: 3px;
border-right-width: 3px;
border-bottom-width: 3px;
border-left-width: 3px;
简写为border-width:3px;

可以看看《别具光芒》这本书,不错的。网上可以搜到
第2个回答  2008-09-25
body里面的margin-left:0px;
这个改成margin-left:auto;margin-right:auto;
第3个回答  2008-09-26
我比较赞赏joier 这种做法,这也是常用的方法,没必要大篇幅的浪费字节数,支持joier 。
第4个回答  2008-09-27
body {margin-top: 0px;
margin-left:0px;
width: 1004px;
position: absolute; }

改为
body {
margin: 0px auto;
width: 1004px;
}