2

对不起,我承认我在 HTML 方面有点新手。但我看不出哪里出错了。我已将页面声明为居中对齐,但由于某种原因对我来说是不可见的,它实际上不会对齐!

我的代码在这里...

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>

<head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type="text/css">
<!--
body,td,th {
    font-size: 14px;
    text-shadow: inherit;
    max-width: 1000px;
    min-width: 600px;
    float: none;
    vertical-align: central;
    position: absolute;
    width: auto;
}
h1 {
    font-size: 40px;
    color: #FFF;
}
h1,h2,h3,h4,h5,h6 {
    font-family: Arial, Helvetica, sans-serif;
    color: #FFFFFF;
}
h2 {
    font-size: 16px;
    color: #666;
}
h3 {
    font-size: 24px;
    color: #FFFFFF;
}
.Headertext2 {
}
h5 {
    font-size: 16px;
    color: #666;
}

h6 {
    font-size: medium;
    color: #000;
}
h4 {
    font-size: 12px;
    color: #FFF;
}
a:link {
    text-decoration: none;
}
a:visited {
    text-decoration: none;
}
a:hover {
    text-decoration: none;
    color: #999;
}
a:active {
    text-decoration: none;
}
      </style>      <title>We'll fix your Potholes!</title>
    </head><center>
 <body bgcolor="#B90D32"> <div id="container" width "1200" align="center" >
<h1>A1Jay Pothole Solutions</h1>
<h3><strong>Permanent Pothole Repair that lasts</strong></h3>
<div id="content" align="center" bgcolor="#FFFFFF"  width"600" class="content">
  <h6>Potholes are a growing problem and cause lasting damage to your vehicle. 
  We here at A1JAy Pothole Solution have the solution. We use only the best products on the market to repair potholes ensuring that the problem is fixed permanently and never returns. Our repairs are professional water tight and permanent. We replace any road markings that may be removed. We respond quickly to repair any holes, therefore stopping the damage to your vehicle.
    Our products are cold lay, fully graded to PSV-60 and all packaging is recyclable. 

    We have different rates depending on the amount of potholes you require permanently repairing, get in touch for details.

    If you have a pothole on your drive, street, place of work, car park, walkway or anywhere else, please get in contact and I will happily give you a free, no obligation quote..  </h6>
<p>&nbsp;</p>

  </div>
</div>
</body>

</html>

如果这个问题已经被问过,我很抱歉,我还在了解 Stack Overflow。提前致谢 :)。

4

2 回答 2

3

让我们从一个精简(和工作)的解决方案开始:http: //jsfiddle.net/WDTCK/1/

要点

  • <center>已过时*(它也是 的非法父body级,在您的示例中未关闭)
  • align=center已过时*
  • 使用 CSS 居中的一种简单方法是为容器元素分配宽度和margin: 0 auto

像这样:

#container {
    margin: 0 auto;
    width: 600px;    
}

小分

  • 总是喜欢与标记分开声明的样式
  • 始终使用 CSS 声明样式(不推荐使用的属性,如bgcolor="#B90D32"
  • 确保正确使用标题。我看到 H1、H3 和 H6。标题应该代表文件的大纲;它们不应仅用于格式化。

这是一个更简洁的示例,它展示了更好的语义:http: //jsfiddle.net/WDTCK/2/

* “已过时且不合格,并且 [...] 不得被作者使用。”

于 2013-03-09T09:03:23.337 回答
-2

把这个放在体内

    <div align = "center">
    <!--somecodes-->
    </div>
于 2013-03-09T09:03:52.903 回答