【问题标题】:HTML Table & Image Problems - FirefoxHTML 表格和图像问题 - Firefox
【发布时间】:2013-11-20 17:26:56
【问题描述】:

我在 Firefox 中查看表格时遇到问题,想知道是否有人可以提供帮助?以下是我的页面在 Firefox 中的显示方式:

http://s15.postimg.org/sx6cn6ktn/Problem_Firefox.jpg

但在 Internet Explorer 中看起来不错:

http://s16.postimg.org/e96xsuwj9/Problem_IE.jpg

我的 HTML 编码如下:

<!DOCTYPE_HTML>
<HTML>
<head>
<link rel="stylesheet" type="text/css" href="css.css">  
<title>Website Name | Album Name</title>

<body>
<div id="wrap">
<div id="logo"><img height="182.135433071px"; width="276.699212598px"; src="ctlogonew.jpg"></img> </div>
<div id="header"><img height="182.135433071px"; width="700px"; src="header1.png"</img>   </div>
<ul>
    <li><a href="#home">Home</a></li>
    <li><a href="#news">News</a></li>
    <li><a href="#news">About</a></li>
    <li><a href="#Album Name">Album</a></li>
    <li><a href="#contact">Contact</a></li>
</ul>
   <hr>
    <!---HEADER ENDS HERE--->


    <h1>Welcome to Website</h1>
    <table border="1px" width="100%">
<col width="40">
<col width="60">
<tr>
    <td><img width="400px" src="homepic.jpg"></img></td>
    <td><p>Welcome to xxxxx - an indie-rock band from Norwich.</p><p> The band are known in the industry for creating great music, with all members, including xxxxxxxxxx having a passion for the genre. Formed in 2010, and based in Norwich, Norfolk, the band have increased massively in popularity since then, selling out all performances for their tour in 2012, with more scheduled for 2013, as well as developing a following in London and on the festival scene.</p><p>The band are known musically for their own brand of indie pop music, containing riffs, hooks and soaring choruses, which has seen them become an online sensation worldwide</p><p>Explore our website for our latest news, details of our latest album <strong><i>Album Name</strong></i>, and purchase merchandise from the store.</p><p> Fans can also explore our Facebook and Twitter profiles, and get in touch with us via the Contact Us page. </p></td>
</div>
</body>
</html>

我的 CSS 编码如下:

#wrap {
width:1000px;
height:1000px;
background-color:black;
margin: 0 auto;
}
#logo {
width:276.699212598px;
height:182.135433071px;
background-color:black;
align:left;
float:left;
margin-top:0px;
margin-left:5px;
margin-right:5px;
}
#header {
width:700px;
height:182.135433071px;
background-color:white;
float:right;
}
ul{
line-height:90px;
list-style-type:none;
text-align:center;
margin:0;
padding:0;
padding-top:6px;
padding-bottom:6px;
}
li{
display:inline;
}
a:link,a:visited {
font-family:Reprise Title, Gill Sans MT, Trebuchet MS, Sans-serif;
font-size:2em;
font-weight:bold;
border-radius:5px;
color:#000000;
background-color:#FFFFFF;
text-align:center;
padding:6px;
text-decoration:none;
text-transform:uppercase;
}
a:hover,a:active {
background-color:#7A991A;
}


  {
  border:1px solid #0000ff;
}
div.desc {
text-align:center;
font-weight:normal;
width:120px;
 margin:2px;
}
hr {
height:4px;
background-color:white;
margin-left:20px;
margin-right:20px;
margin-bottom:30px;
}
/*HEADER ENDS HERE*/
h1 {
font-family:Reprise Title, Gill Sans MT, Trebuchet MS, Sans-serif;
font-size:2em;
color:#FFFFFF;
font-weight:bold;
margin-left:20px;
}
p {
font-family: Gill Sans MT, Trebuchet MS, Sans-Serif;
font-size: 1em;
color: #FFFFFF;
}


table {
font-family: Gill Sans MT, Sans-Serif;
color: #FFFFFF;
padding: 3px;
}

非常感谢任何帮助!

非常感谢。

【问题讨论】:

  • 您指向Problem_IE 页面的链接实际上指向Problem_Firefox.jpg
  • 您的文档类型错误,这可能会将两个浏览器都打入“怪癖模式”(本质上是一种 IE5 兼容模式),从而导致各种疯狂。下划线应该是空格,即&lt;!DOCTYPE html&gt;
  • 在开始 &lt;body&gt; 之前,您没有结束 &lt;/head&gt; 标记。
  • col width 在 HTML5 中已过时;你应该改用 CSS。

标签: html css internet-explorer firefox


【解决方案1】:

为 colgroup 中的值添加一个单位。使用您的代码似乎对我有用。

col width="40%"

col width="60%"

【讨论】:

    【解决方案2】:

    HTML:

    • 正如 cmets 中所说,您的 DOCTYPE 拼写错误,导致文档进入 Quirks 模式。而且不同的浏览器有不同的怪癖,所以如果你追求浏览器的互操作性,就不要使用它。
    • 如今,使用小写字母编写标记名称是一种很好的做法,因此&lt;html&gt; 而不是&lt;HTML&gt;。当然,您可以随心所欲地编写它们;保持一致。
    • 缺少&lt;/head&gt; 结束标记,但这也不是错误。这些天不建议这样做。我的意思是,省略该标签所做的只是节省 8 或 9 个字节。
    • 图像的宽度和高度属性存在错误。那些应该只包含整数。此外,谁听说过 182.13 像素高的图像?
    • img 标签中的那些分号是错误的。摆脱它们。
    • 第二张图片也缺少&gt;
    • 没有&lt;/img&gt; 结束标签之类的东西。
    • 您的 img 没有 alt 属性。
    • 您的评论有奇数个破折号。把它们理顺。
    • 在表格中,宽度属性再次关闭。真的,你应该阅读你的 CSS。如今,所有这些宽度和高度属性都已无用。
    • &lt;i&gt;&lt;strong&gt; 的结束标签是错误的。此外,您的意思是&lt;cite&gt;,而不是&lt;i&gt;&lt;strong&gt;
    • 缺少&lt;/table&gt; 结束标记。

    CSS:

    • align 不是样式属性。
    • 你没有清理你的花车。养成经常清理花车的习惯。
    • 始终在字体系列名称周围加上引号是个好主意,尤其是当它们包含空格时。
    • 只有一个样式规则没有选择器。

    如果您纠正了所有这些错误,您的网站可能会在不同浏览器中看起来更加相似。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-10-28
      • 2011-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-08
      相关资源
      最近更新 更多