Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么不是';我的HTML是否与中心对齐?_Html_Alignment_Center - Fatal编程技术网

为什么不是';我的HTML是否与中心对齐?

为什么不是';我的HTML是否与中心对齐?,html,alignment,center,Html,Alignment,Center,对不起,我承认我对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

对不起,我承认我对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>


让我们从一个精简的(有效的)解决方案开始:

要点
  • 已过时*(它也是
    body
    的非法父项,在您的示例中未关闭)
  • align=center
    已过时*
  • 使用CSS将内容居中的一种简单方法是为容器元素指定一个宽度和
    边距:0 auto
像这样:

#container {
    margin: 0 auto;
    width: 600px;    
}
小结
  • 始终首选与标记分开声明的样式
  • 始终使用CSS声明样式(而不是像
    bgcolor=“#B90D32”
    这样不推荐使用的属性)
  • 确保正确使用标题。我看到H1、H3和H6。标题应代表文档的大纲;它们不应仅用于格式化
下面是一个更清晰的示例,它演示了更好的语义:


*把这个放在身体里

    <div align = "center">
    <!--somecodes-->
    </div>


请把这个放到提琴里-哇,谢谢。。。我真的需要整理一下。谢谢你,也谢谢你给我看JSFIDLE。为你竖起大拇指!!没问题。我添加了另一个示例来帮助您完成剩余的标记。还请记住,您可以使用验证代码。这不适用于此giphy:除非我需要将它们提供的所有内联css移动到相同的外部css,并更改一些我丢失的内容。