在以下情况下,如何使用: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