2012-05-19 19 views
4

我對TH標記Table使用了一條通用規則,但它干擾了所有事情。我使用的規則如下:CSS:對多個ID使用單個規則

th 
{ 
    color: #fff; 
    background: #7d7e7d; 
} 

但現在我想指定幾個表的Ids,以便它根本不影響其他表。我做的是:

#id1,#id2 th 
{ 
    color: #fff; 
    background: #7d7e7d; 
} 

它做了什麼顏色傳播以及。我如何完成我的任務?

回答

6

你需要指定th兩次作爲逗號分隔整個選擇:

#id1 th, #id2 th 
{ 
    color: #fff; 
    background: #7d7e7d; 
} 

否則你選擇整個#id1以及剛剛#id2 th

+0

也有https://developer.mozilla.org/en/CSS/%3A-moz-any,如果你對實驗性功能很好。 – luiscubal

+0

@luiscubal:這就是':-moz-any(#id1,#id2)th'或者希望/最終,':匹配(#id1,#id2)th' – BoltClock

+0

@BoltClock謝謝你Bro!簡單而重要。 – Volatil3