日期:2014-05-17  浏览次数:20575 次

大家帮我看几行代码,层如何居中呀,总是搞不定。
下面是代码,我把层宽度定成788,里面含有一个表格,我想让这个层能够居中。我代码中的设置为何无效呀?

<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 "   />
<title> 无标题文档 </title>
<style   type= "text/css ">
<!--
#Layer1   {
position:固定;
left:auto;
top:0px;
width:788px;
height:172px;
z-index:1;
background-color:   #0066CC;
background-position:   center;
clear:   both;
right:   auto;
}
-->
</style>
</head>

<body>
<div   align= "center "   id= "Layer1 ">
    <table   width= "100% "   border= "1 "   cellspacing= "0 "   cellpadding= "0 ">
        <tr>
            <td> &nbsp; </td>
        </tr>
        <tr>
            <td> &nbsp; </td>
        </tr>
    </table>
</div>
</body>
</html>

------解决方案--------------------
position:固定;

=.=......飘过,吃饭了...
------解决方案--------------------
如果页头没有XHTML DTD margin:0 auto好象不起作用
<style>
body{text-align:center}
#Layer1{width:788px; margin:0 auto}
</style>
------解决方案--------------------
body
{text-align:center}