Chr*_*ell 2 css css-selectors internet-explorer-7
我希望将所有th元素的样式设置为相同(黑色背景上的白色文本),除了几个不需要这种格式的用法之外 - 在这种情况下,我将一个类添加no-headers到table元素中.
th {background-color: #000000; color:#FFF;}
table.no-headers th {color:inherit; background-color:inherit ;border:inherit; }
Run Code Online (Sandbox Code Playgroud)
所以这里有一些示例标记,如果你需要一些
<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>
Run Code Online (Sandbox Code Playgroud)
这在IE 8/9和FF和Chrome中运行良好,但在IE 7中不行.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>
Run Code Online (Sandbox Code Playgroud)
甚至那不起作用 - 我感觉我正在做一些非常明显的愚蠢/错误的事情 - 但是它再次在其他浏览器中工作正常!
任何帮助非常感谢.