2011-08-09 21 views
2

我想要所有我的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> 

,甚至不工作 - 我也感覺像我在做一些真正明顯的愚蠢/錯 - 但是再次在其他瀏覽器中正常工作!

任何幫助非常感謝。

+0

[類似的問題](http://stackoverflow.com/questions/511066/ie7-css-inherit-problem) –

回答

5

IE7不識別inherit關鍵字(除了一些模糊的屬性)。

最好的辦法是手動指定默認顏色。

+0

或者是粗魯的:別擔心,你沒有做任何愚蠢的事情。 IE7是一個愚蠢的。 – BoltClock

1

IE7不支持樣式繼承。這是在IE8中引入的。

請參見:IE7 CSS inheritance does not work

這是不是一個巨大的問題,因爲IE8是從IE7通用升級,不像IE9,這是僅適用於Windows NT6以上。