我想要所有我的th
元素都是相同的樣式(黑色背景上的白色文本),除了一些不需要此格式的用法 - 在這種情況下,我添加了一類no-headers
添加到表格元素。IE 7沒有使用最具體的CSS規則
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>
能正常工作,在IE 8/9和FF和Chrome,但不是在IE 7 IE 7就不會使用第二條規則 - 儘管它更具選擇性。
事實上,我已經嘗試過各種方法來解決這個問題 - 一切都無濟於事。
我曾嘗試加入個元素的無頭類太
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>
,甚至不工作 - 我也感覺像我在做一些真正明顯的愚蠢/錯 - 但是再次在其他瀏覽器中正常工作!
任何幫助非常感謝。
[類似的問題](http://stackoverflow.com/questions/511066/ie7-css-inherit-problem) –