Making an svg image object clickable with onclick, avoiding absolute positioning

前端 未结 13 1125
轻奢々
轻奢々 2020-12-02 13:54

I have tried to change the images on my site from img to svg, changing img tags to embed and object tags. Bu

13条回答
  •  -上瘾入骨i
    2020-12-02 14:47

    I got this working accross the latest versions of Firefox, Chrome, Safari and Opera.

    It relies on a transparent div before the object that has absolute position and set width and height so it covers the object tag below.

    Here it is, I've been a bit lazy and used inline styes:

    I used the following JavaScript to hook up an event to it:

    
    

提交回复
热议问题