div+css实现。在任何分辨率的电脑上,范围A永远居中,并且固定宽度!!

div+css实现。在任何分辨率的电脑上,范围A永远居中,并且固定宽度!!!怎么实现?
A宽度定为1000px吧。。。。。

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.a{
position:fixed;
left:50%;
top:0px;
bottom:0px;

width:1000px;
margin-left:-500px;
background:#f00;
}
</style>
</head>
<body>
<div class="a">A</div>
</body>
</html>
楼上的0 auto方法也是没有问题。但是需要注意的是使用这个css 的父节点是不是根节点

满意好评
温馨提示:答案为网友推荐,仅供参考
第1个回答  2016-10-25

HTML:

<div style="width:1000px; height:200px; border:1px solid red; margin:0 auto;"></div>

你只要设置其margin属性值为0 auto就可以实现了。如以上代码所示。