在以下情況下,如何使用:not()
將div.note em
從粗體中排除?CSS3:不是()選擇器
div#content em {
font-weight: bold;
}
/* I want to remove the following
in favor of the :not selector being applied to the above */
div#content div.note em {
font-weight: normal;
}
PS:這是一個精簡的例子,其實我有很多的樣式div#content em
,我想申請到一切,除了div.note em
。這就是爲什麼我不希望覆蓋所有這些手動lateron ...
由於後代組合子的性質,單靠':not()'不能可靠地做到這一點。您必須創建一些取決於您的HTML結構的複雜選擇器,並且努力做到這一點不值得僅僅使用您的'div#content div.note em'覆蓋規則。 – BoltClock 2012-04-28 15:06:03
(我不知道這樣的選擇器是否可能,這取決於你的標記。) – BoltClock 2012-04-28 15:16:38
好吧,標記與CSS建議非常相似......想象一下'div#content'就像'article'然後'div.note'成爲該文章中突出顯示的信息框,除了'p','blockquote',圖像等其他所有內容外。 – Ben 2012-04-28 15:26:47