【发布时间】:2013-09-15 09:04:48
【问题描述】:
我正在使用一个包含几个表格的简单 HTML 页面,我想更改页面的背景颜色。当我尝试更改 bgcolor 时,它只会更改页面底部的一条细线,它在此处显示页脚文本,而不是背景颜色。我不想改变表格的颜色,而只是改变后面的颜色,以便页面的外边缘具有背景色,而中心有一个带有内容的白色表格。
这是表格中的代码草稿:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Language" content="en-gb">
<title>Your Title Here</title>
<style>
LI.MsoNormal {
FONT-SIZE: 12pt; FONT-FAMILY: "Times New Roman"; mso-style-parent: ""; margin- left:0in; margin-right:0in; margin-top:0in; margin-bottom:0pt
}
.H1 {
FONT-SIZE: 36px; : #d70305
}
H1 {
FONT-FAMILY: Tahoma, Arial, Helvetica, sans-serif
}
H2 {
FONT-SIZE: 20px; COLOR: #000000
}
H2 {
FONT-FAMILY: Tahoma, Arial, Helvetica, sans-serif
}
.style22 {font-size: 12px}
.style13 {font-family: Tahoma;
font-size: 24px;
font-weight: bold;
}
.style16 { font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 24pt;
color: #000000;
font-weight: bold;
}
.style17 {color: #993300}
.style3 {font-family: Arial, Helvetica, sans-serif;
font-size: 14px;
}
.style4 {color: #666633;
font-size: 12px;
}
.style6 {font-family: Arial, Helvetica, sans-serif; font-size: 10pt; }
.style90 {font-size: 18pt}
.headline1 {
font-family: Tahoma, Geneva, sans-serif;
font-size: 24pt;
font-weight: bold;
color: #C00;
}
</style>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#242424">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" background="images/top.jpg">
<img src="images/header.jpg" width="873" height="233"></td>
</tr>
<tr>
<td style="background-image:url(images/middle.jpg); background-repeat:repeat-x; background-color:#ffffff">
<table width="859" border="0" align="center" cellpadding="0" cellspacing="0" background="images/sides.jpg">
<tr>
<td><table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<div align="center">
<!--Table Content here-->
</div>
</td>
</tr>
</table>
</table>
</td>
<tr>
<td align="center" background="images/bottom.jpg">
<img src="images/footer.jpg" width="873" height="126"></td></tr>
</table>
<font color="#999999" size="2" face="Tahoma">footer text here</font></div>
</body>
</html>
【问题讨论】:
-
警告:您的 Doctype 触发 Quirks mode,其中浏览器会模拟旧浏览器中的错误,不支持某些功能,并且彼此之间的一致性明显降低。你应该避免它。
-
您可以通过在您的 CSS 中保留所有样式来改进您的代码,而不是直接在您的 HTML 中使用诸如
border、topmargin等 HTML 属性。这样您就可以更轻松地维护网站并更快地找到适合此类调整的位置。 -
您的 Doctype 设置为 HTML 4,并且您使用的
-
代码对我来说很好用。我猜你的桌子正在占据你的整个页面。给出一个确定的大小或使用较小的表格来查看变化。
标签: html colors background