Why does the general-sibling combinator allow toggling pseudo-element's content, but not the adjacent-sibling?

后端 未结 2 1121
-上瘾入骨i
-上瘾入骨i 2020-11-29 07:55

In this question \"CSS3 Selector That Works like jQuery's .click()?\" I posted an answer using the :checked state of an input, of type=\"

2条回答
  •  情书的邮戳
    2020-11-29 08:19

    This is a long-standing bug in WebKit browsers related to the use of certain dynamic pseudo-classes with next-sibling combinators. This happens whether you're applying styles to the sibling element itself or a pseudo-element of that sibling element.

    I don't know if anybody has filed a bug report yet, but this has been seen rather frequently on the site:

    • Webkit bug with `:hover` and multiple adjacent-sibling selectors
    • CSS adjacent sibling selectors, Safari and

    Strangely it was also reported that Chrome had issues with the general sibling combinator, but as you note it works in your given scenario:

    • Why doesn't this CSS selector work: a:hover ~ span?

    So either that was fixed, or something else triggers/triggered it.

提交回复
热议问题