Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.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_Css - Fatal编程技术网

Html 尝试在每种浏览器中居中显示页面——在大多数情况下都有效,在其他情况下则无效

Html 尝试在每种浏览器中居中显示页面——在大多数情况下都有效,在其他情况下则无效,html,css,Html,Css,我已经为这个站点完成了一组非常简单的html页面: 在大多数设备上,它在浏览器窗口的大小范围内正确居中,两侧的边距相等 不过,我有一些关于特定问题机器的报告: 在ie10(大屏幕笔记本电脑)上,它看起来向右偏中心 在iPhone4G(纵向或横向)上,页面向右偏离中心 我想知道是否有人能告诉我设备/浏览器特定的线条要放在顶部,以便始终居中 我相信问题来自于我在页面顶部识别(或缺少)文档类型,并认为我应该在顶部添加一些If语句,以便为某些浏览器提供更严格的文档类型 现在,它只被标识为html。如果

我已经为这个站点完成了一组非常简单的html页面:

在大多数设备上,它在浏览器窗口的大小范围内正确居中,两侧的边距相等

不过,我有一些关于特定问题机器的报告:

在ie10(大屏幕笔记本电脑)上,它看起来向右偏中心

在iPhone4G(纵向或横向)上,页面向右偏离中心

我想知道是否有人能告诉我设备/浏览器特定的线条要放在顶部,以便始终居中

我相信问题来自于我在页面顶部识别(或缺少)文档类型,并认为我应该在顶部添加一些If语句,以便为某些浏览器提供更严格的文档类型

现在,它只被标识为
html
。如果我将描述更改为更详细的类型,它将更改居中

我感谢你的帮助。谢谢


下面是上面示例中的文本--environment.php

环境-土壤出版社

/*写在这里面,它就会居中*/
我只是用内联CSS作为div的一小行代码


希望这就是你所需要的。

为ie10笔记本电脑找到了答案。。。他们的屏幕宽度小于主图像的1200像素宽度。。。因此,它在左侧显示正常,在右侧出血,使其看起来偏离中心

使中心图像宽900像素,现在它工作完美

目前还不确定iphone5,但希望它也能起到同样的作用

我之所以选择直接使用老式的html和css,是因为整个页面只有两幅图像。一个带有链接的标题和一个主体图像。这意味着,一旦我获得正确的居中位置,它可以在每个浏览器上看起来完全相同。如果我尝试使用CSS来集中,我会遇到版本问题。因为我没有真正的文本,没有一致的结果似乎是浪费时间


谢谢你的回复!将在另一个网站上使用它:)

不要使用
表格
来进行布局。您正在使用一些非常古老的HTML。使用CSS设置样式,而不是像
width
background
,等等属性,因为CSS重置总是有用的。
<html>
<head><title>Environmental - SoilExpress</title>
<link rel="shortcut icon" href="/favicon.ico">
<link href='http://fonts.googleapis.com/css?family=Lato:300,900' rel='stylesheet' type='text/css'>
<style type="text/css">
<!--
img { border-style: none;}
td {color:#ffffff; font-size:15px; font-family: 'Lato', sans-serif; font-weight: 300; }
.footer {color:#999999; font-size:12px; font-family: 'Lato', sans-serif; font-weight: 300; }
.whiteheader {color:#ffffff; font-size:20px; font-family: 'Lato', sans-serif; font-weight: 300; }
.redheaderblower {color:#cc0000; font-size:30px; font-family: 'Lato', sans-serif; float: right; font-weight: 900; }
.redheadereow {color:#ff0000; font-size:30px; font-family: 'Lato', sans-serif; float: left; font-weight: 900; }
-->
</style>
</head>
<body background='/web_images/level3-background.png' marginheight="0" topmargin="0">
<!-- master table -->
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr><td width='50%'><img src='/web_images/trs.gif' height='1' width='1'></td>
<td valign="top" width="1200">
<!-- content table -->
<table width="1200" cellpadding="0" cellspacing="0" border="0">
<tr>
<td valign="top" width="1200" colspan='6'>
<a href='/'>
<img src='/web_images/row-header.png' width='1200' height='120' style='vertical-align: top;'>
</a>
</td>
</tr>
<!-- ROW navigation -->
<tr>
<td>
<img src='/web_images/row-nav1.png' width='207' height='136' style='vertical-align: top;'>
</td>

<td>
<a href='/safety.php'>
<img src='/web_images/row-nav-safety.png' width='185' height='136' style='vertical-align: top;'>
</a>
</td>

<td>
<a href='/equipment.php'>
<img src='/web_images/row-nav-equipment.png' width='220' height='136' style='vertical-align: top;'>
</a>
</td>

<td>
<a href='/capable.php'>
<img src='/web_images/row-nav-capable.png' width='165' height='136' style='vertical-align: top;'>
</a>
</td>

<td>
<a href='/environmental.php'>
<img src='/web_images/row-nav-environmental.png' width='218' height='136' style='vertical-align: top;'>
</a>
</td>

<td>
<img src='/web_images/row-nav1.png' width='205' height='136' style='vertical-align: top;'>
</td>

</tr>
<tr>
<td valign="top" width="1200" colspan='6'>
<img src='/web_images/environmental.png' width='1200' height='750'>
</td>
</tr>
<tr>
<td valign="top" width="1200" colspan='6'>
<table width='1200' cellspacing='0' cellpadding='0' border='0'>
<tr><td bgcolor='black'>
<img src='/web_images/trs.gif' width='381' height='1'>
</td>
<td bgcolor='black'>
<a href='/contact.php'>
<img src='/web_images/footer-contact-link.png' width='123' height='92' style='vertical-align: top;'>
</a>
</td>
<td bgcolor='black'>
<a href='/'>
<img src='/web_images/footer-home-link.png' width='196' height='92' style='vertical-align: top;'>
</a>
</td>
<td bgcolor='black'>
<img src='/web_images/footer-copyright.png' width='500' height='92' style='vertical-align: top;'>
</td>
</tr>
</table>
</td>
</tr>

</table>
</td><td width='50%'><img src='/web_images/trs.gif' height='1' width='1'></td>
</tr></table>
</body></html>
<span style="position:absolute;top:0px;left:0px;background-color:white;width:100%;font-family:Trebuchet MS,Liberation Sans,DejaVu Sans,sans-serif;font-size:20px;">
     <div align="center">
          <div style="width:980px;text-align:left;">
          /*Write within this and it will be centered*/
          </div>
     </div>
</span>