bxc1115 2015-05-25 03:37 采纳率: 0%
浏览 4010

如何将html全部元素居中

html小白一个。遇到的代码想将它居中,然后尝试了align="center"和

都没有效果。代码精简后是这样的:
 <!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>待居中</title>
    <style type="text/css">
.导航栏 {
    position: absolute;
    width: 1260px;
    top: 61px;
    height: 33px;
    left: 12px;
    font-size: 24px;
    background-color: #128BDA;
    color: #FFF;
    font-family: "Arial Black", Gadget, sans-serif;
    font-weight: bold;
    z-index: 100;
}
.gywm {
    position: absolute;
    left: 12px;
    top: 800px;
    width: 474px;
    height: 93px;
}
.hzzd {
    position: absolute;
    left: 529px;
    top: 800px;
    width: 764px;
    height: 121px;
}
.
body {
    background-image: url();
    align="center";
}
.back {
    position: absolute;
    left: 10;
    top: 0px;
    z-index: 0;
}
</style>  
</head>

<body>
<div>
<div class="back"><img src="images/back.jpg" width="1280" height="909" border="0" align="absmiddle" /></div>
<div class="hzzd">
  <p>合作站点</p>
</div>  
<div class="gywm">
  <h4>关于我们</h4>
</div>
<p align="left">&nbsp;</p>
<p align="left">&nbsp;</p>
<div class="导航栏"><strong>首页</strong></div>
<div class="导航栏">
  <table width="1260" border="0" align="center">
    <tr>
      <td width="115" scope="row"><a href="index.php" target="_blank"style="color:#FFFBF0">首页</a></td>
      <td width="209">1</td>
    <td width="189">2</td>    </tr>
</body>
</html>
  • 写回答

9条回答

  • bxc1115 2015-05-25 03:38
    关注

    额。。为什么上传之后变成这个样子的了。。

    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条