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

标签 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

最佳答案

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

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

Read More

关于html - 如何在不同浏览器的 html 中用背景颜色填充 html 表格单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4146236/

相关文章:

javascript - 如何在 execCommand formatBlock 'p' 标签中添加 class 或 id 或 CSS 样式?

javascript - 覆盖 tr onclick

html - 仅针对文本将文本与背景色居中对齐

css - 修复我网站上 div 之间的奇怪间距

css - 虚线下划线无法在 Chrome 中正确呈现

HTML表格背景

html - 缩小页面时不可点击的元素

css - Div 背景未设置

python - If equal 在 Django 模板中不起作用

javascript - 除了一个元素向右浮动外,所有内容都居中的导航栏