使一个html svg对象也是一个可点击的链接 [英] make an html svg object also a clickable link
本文介绍了使一个html svg对象也是一个可点击的链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的HTML页面中有一个SVG对象,并且将它包装在一个锚点中,所以当点击svg图像时,它会将用户带到锚点链接。
< a href =http://www.google.com/>
< object data =mysvg.svgtype =image / svg + xml>
< span>您的浏览器不支援SVG图像< / span>
< / object>
< / a>
当我使用此代码块时,单击svg对象不会将我带到Google。在IE8中, span文本是可点击的。
我不想修改我的svg图片以包含标签。
我的问题是,如何让svg图像可点击?解析方案
最简单的方法是不使用< object>。相反,使用< img>标记,锚点应该可以正常工作。
I have an SVG object in my HTML page and am wrapping it in an anchor so when the svg image is clicked it takes the user to the anchor link.
<a href="http://www.google.com/">
<object data="mysvg.svg" type="image/svg+xml">
<span>Your browser doesn't support SVG images</span>
</object>
</a>
When I use this code block, clicking the svg object doesn't take me to google. In IE8< the span text is clickable.
I do not want to modify my svg image to contain tags.
My question is, how can I make the svg image clickable?
解决方案
The easiest way is to not use <object>. Instead use an <img> tag and the anchor should work just fine.
这篇关于使一个html svg对象也是一个可点击的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文