IE 7未使用最具体的CSS规则

IE 7未使用最具体的CSS规则,css,internet-explorer-7,css-selectors,Css,Internet Explorer 7,Css Selectors,我希望所有th元素的样式都相同(黑色背景上的白色文本),除了一些不需要这种格式的用法之外——在这种情况下,我向table元素添加了一类no headers th {background-color: #000000; color:#FFF;} table.no-headers th {color:inherit; background-color:inherit ;border:inherit; } 如果需要,这里有一些示例标记 <table><tr><th&g

我希望所有
th
元素的样式都相同(黑色背景上的白色文本),除了一些不需要这种格式的用法之外——在这种情况下,我向table元素添加了一类
no headers

th {background-color: #000000; color:#FFF;}
table.no-headers th {color:inherit; background-color:inherit ;border:inherit; } 
如果需要,这里有一些示例标记

<table><tr><th>This has a black bground</th></tr></table>
<table class="no-headers"><tr><th>This inherits bground from parent</th></tr></table>
这有一个黑色背景
这将从父级继承bground
这在IE8/9、FF和Chrome中运行良好,但在IE7中不起作用。 IE 7不会使用第二条规则,尽管它更具选择性。
事实上,我已经尝试过各种方法来解决这个问题,但都没有用

我也尝试过在th元素上添加no headers类

th {background-color: #000000; color:#FFF;}
th.no-headers {color:inherit; background-color:inherit ;border:inherit; } 

<table><tr><th class="no-headers">This inherits bground from parent</th></tr></table>
th{背景色:#000000;颜色:#FFF;}
th.no-headers{color:inherit;背景色:inherit;边框:inherit;}
这将从父级继承bground
即使这样也不起作用——我感觉自己在做一些很明显很愚蠢/错误的事情——但在其他浏览器中它也可以正常工作


非常感谢您的帮助。

IE7不识别
inherit
关键字(除了一些模糊属性)


最好是手动指定默认颜色。

根据这篇文章:IE直到IE8才支持inherit。因此,您必须专门指定颜色、背景和边框。

IE7不支持样式继承。这是在IE8中引入的

见:


这不是一个大问题,因为IE8是IE7的通用升级,而IE9只适用于Windows NT6及以上版本。

或者简而言之:别担心,你没有做过什么蠢事。IE7是个愚蠢的人。