Css hover sometimes doesn't work on svg paths

前端 未结 3 780
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-06 04:08

I got a svg with paths, and i have css hover on them, but hover sometimes work, sometimes not.

What can be the problem?

相关标签:
3条回答
  • 2020-12-06 04:30

    The following fixed my problem with svg and jQuery hover and alike.

    svg, svg * {
      pointer-events: none;
    }
    
    0 讨论(0)
  • 2020-12-06 04:46

    There's no fill so the interior does not catch mouse events by default and therefore hover doesn't react to that. Changing pointer-events to all will fix it in this case:

    path{
        fill:none;
        stroke:black;
        pointer-events:all;
    }
    
    0 讨论(0)
  • 2020-12-06 04:53

    This always works for me when using object tag

    object {
        pointer-events: none;
    }
    
    0 讨论(0)
提交回复
热议问题