边界的CSS完全不能在Internet Explorer中正常工作

时间:2012-04-11 17:46:05

标签: css

我正在使用以下CSS完全绑定<tr>

<style type="text/css">
    tr.top td { border-top: thin solid black; }
    tr.bottom td { border-bottom: thin solid black; }
    tr.row td:first-child { border-left: thin solid black; }
    tr.row td:last-child { border-right: thin solid black; }
</style>

它在Mozilla Firefox中完美运行,但在Internet Explorer中,它不会与最后一个<td>接壤,如下面的快照所示。

在Firefox中,它显示下表。

enter image description here

但是,在Internet Explorer(8)中,它显示如下表格。

enter image description here

意味着在上面的CSS中,这个CSS类tr.row td:last-child { border-right: thin solid black; }在IE中不起作用。这是什么解决方案?我正在使用IE 8。

2 个答案:

答案 0 :(得分:3)

IE 8不支持:last-child伪类(CSS 3),但它确实支持:first-child(CSS 2.1)

CSS Compatibility and Internet Explorer

您需要为最后一个单元格使用不同的选择器,例如自定义类名称。

答案 1 :(得分:1)

顺便说一下,如果你在css文件中声明边框,而不是在样式之后,在TD标签内怎么办?我被告知IE8有一些边框渲染的bug。将它发布在这里,看看它是否有效。

另一个疑问,你为什么不使用1px而不是瘦!?