网页居中问题,高手进

来源:百度知道 编辑:UC知道 时间:2024/05/11 03:03:16
<!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=gb2312" />
<title>石家庄洁美环境服务总公司</title>
<style type="text/css">

<!--
#Layer1 {
position:absolute;
left:356px;
top:224px;
width:448px;
height:24px;
z-index:1;
}
#Layer2 {
position:absolute;
left:264px;
top:279px;
width:187px;
height:34px;
z-index:2;
}
#Layer3 {
position:absolute;
left:464px;
top:277px;
width:174p

你是用什么做的,div还是table,如果是table做的,就选中最外面一层的表格,在属性面板中设置居中就行了

拜托,你问这个问题本身就不专业,又看不到你的body的代码,怎么知道你是怎么做的,实现居中的方式很多,楼上的人说的也可以,可这样的话你的网页中的所有元素就都居中了

<body>
<div id="container">
<div id="header"></div>
<div id="main"></div>
<div id="footer"></div>
</div>
</body>

这里container是最外面的div,包住所有div
css只需设置
#container{
margin-left:auto;
margin-right:auto;
}
就可以居中,也可以在这里设置网页的宽度

选中表格,在属性栏中将其对齐方式设为“居中对齐”。

<div>
<table align="center">
<tr>
<td></td>
</tr>
</table>
</div>

在两个HTML<body></body>之间加上<center>居中代码

例如:
<body>
<center>
HTML居中代码!
</center>
</body>