如何在html中为不同的浏览器填充带有背景颜色的html表格单元格

时间:2010-11-10 15:44:55

标签: html css

我有以下HTML,它在最后一列创建了一个带滚动条的表。我的问题是IE呈现的方式与Firefox不同。任何线索都将非常感激。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Test of tables and CSS</title>
<style type="text/css">
td
{
   border:solid 1px #000000;
   padding:2px 2px 2px 2px;
    }
</style>
</head>
<body>
<table cellspacing="0" style="border:solid 1px #000000;border-collapse:separate;padding:0 0         0 0;">
<tr>
<td>Col 1 1</td>
<td>Col 1 2</td>
<td rowspan="5" style="width: 1px; padding: 0 0 0 0;height:100%;"><table cellspacing="0" style="border: none; height:100%;border-collapse: collapse; padding: 0 0 0  0;">
<tr><td style="border: none; height: 1px; background-color: #C9D8FC;"><img alt="" src="../img/ico/ScrollUp.gif" style="border: none;" /></td></tr>
    <tr><td style="border: none; height: auto; background-color: #C9D8FC;"></td></tr>
<tr><td style="border: none; height: 1px; vertical-align: bottom; background-color:#C9D8FC;"><img alt="" src="../img/ico/ScrollDown.gif" style="border:none;" /></td></tr>
</table></td>
</tr>
<tr>
<td>Col 2 1</td>
<td>Col 2 2</td>
</tr>
<tr>
<td>Col 3 1</td>
<td>Col 3 2</td>
</tr>
<tr>
<td>Col 4 1</td>
<td>Col 4 2</td>
</tr>
<tr>
<td>Col 5 1</td>
<td>Col 5 2</td>
</tr>
</table>
</body></html>

火狐:
alt text

IE 8:
alt text

4 个答案:

答案 0 :(得分:1)

阅读本文以更好地了解高度渲染http://apptools.com/examples/tableheight.php

答案 1 :(得分:0)

身高:自动;这在IE中无法正常工作,

尝试添加display:block

答案 2 :(得分:0)

这是问题吗?

vstyle="... should be style="... 

您也可能想要在表格中添加一个类而不是将样式设置为内联,这样可以更容易阅读,但不会对渲染产生影响

答案 3 :(得分:0)

您可以在标题中使用条件注释将特定样式声明发送到Internet Explorer吗?

<!--[if IE]>
Only IE will output what's between these brackets, style declarations etc.
<![endif]-->

Read More