我想知道是否可以将伪类“嵌入”到彼此内部。我有一种预感,你不能,但我只是想确保我没有语法错误。
这是我正在尝试做的一个例子:
p.description { margin-bottom: 20px; }
鉴于这种风格,如果您只希望在不是最后 p.description 的比赛中发生这种情况,是否可以执行以下操作?
p.description:not(p.description:last-child)
自然地,我有两种风格,像这样:
p.description { margin-bottom: 20px; }
p.description:last-child { margin-bottom: 0; }
...但如果可以在一行中完成,那似乎很浪费。
非常感谢!
最佳答案
是的,您的问题标题:
p.description:not(:last-child)
不,问题正文中的 CSS 示例
p.description:not(p.description:last-child)
The negation pseudo-class,
:not(X)
, is a functional notation taking a simple selector (excluding the negation pseudo-class itself) as an argument.A simple selector is either a type selector, universal selector, attribute selector, class selector, ID selector, or pseudo-class.
关于css - 可以在 :not() pseudo-class? 内部使用 CSS 伪类吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5720064/