Webkit bug with `:hover` and multiple adjacent-sibling selectors

前端 未结 3 553
时光取名叫无心
时光取名叫无心 2020-11-27 17:24

Safari and Chrome, as well as Opera and Firefox, can handle the :hover pseudo-class and adjacent-sibling selectors:

a:hover + div {}

<
相关标签:
3条回答
  • 2020-11-27 18:02

    you can overcome Webkit's pseudo classes + general/adjacent sibling selectors bugs by faking animation on the body element:

    body { -webkit-animation: bugfix infinite 1s; }
    
    @-webkit-keyframes bugfix { 
      from { padding: 0; } 
      to { padding: 0; } 
    }
    

    you can check it out here: http://jsfiddle.net/jalbertbowdenii/ds2yY/1/

    0 讨论(0)
  • 2020-11-27 18:18

    Alternatively, the fix can be applied only to the elements that are having the update issue rather than to the body element:

    http://jsfiddle.net/ds2yY/12/

    .force-repaint { -webkit-animation: bugfix infinite 1s; }
    
    @-webkit-keyframes bugfix {
        from { fill: 0; }
        to { fill: 0; }
    }
    
    0 讨论(0)
  • 2020-11-27 18:21

    Easy Fix without Animations

    Handled a similar issue here, where this idea of changed pseudo-classes solved it (note: nth-child(n) will always match):

    div:hover + a:nth-child(n) + div
    
    0 讨论(0)
提交回复
热议问题