CSS negation pseudo-class :not() for parent/ancestor elements

后端 未结 2 1318
挽巷
挽巷 2020-11-22 02:09

This is driving me nuts:

HTML:

Hello World!

CSS:

2条回答
  •  爱一瞬间的悲伤
    2020-11-22 02:48

    The element is not a

    . The element is not a
    .

    So the condition "has an ancestor that is not a

    " will be true for all elements.

    Unless you can use the > (child) selector, I don't think you can do what you're trying to do - it doesn't really make sense. In your second example,

    is not a div, so that matches *:not(div) too.

提交回复
热议问题