在SVG文本元素中插入HTML代码 [英] Insert HTML code inside SVG Text element

查看:143
本文介绍了在SVG文本元素中插入HTML代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个svg:文本节点,我想在其中添加HTML代码。实际上,我的代码是:

 < text x =10y =54text-anchor =start类= barLegend >你好!< /文本> 

我想这样做:

 < text x =10y =54text-anchor =startclass =barLegend>< a href ='www.gmail.com > Gmail和LT; / A>< /文本> 

当然,我希望链接能够正常工作,但它只是显示所有的HTML。 p>

任何想法?

解决方案

请看这里:



http://web.archive.org/web/20120418122612/http://ajaxian.com/archives/foreignobject-hey-youve-got-html-in-my-svg

SVG foreignObject标签允许您将非SVG内容混合到您的页面中。例如,您可以在SVG元素的中间放置一些HTML。


I have an svg:text node, and I want to add HTML code inside it. Actually, my code is:

<text x="10" y="54" text-anchor="start" class="barLegend">Hello!</text>

And I want to put something like this:

<text x="10" y="54" text-anchor="start" class="barLegend"><a href='www.gmail.com'>Gmail</a></text>

Of course, I want the link working, but, it is just displaying all the HTML.

Any Idea?

解决方案

Take a look here :

http://web.archive.org/web/20120418122612/http://ajaxian.com/archives/foreignobject-hey-youve-got-html-in-my-svg

The SVG foreignObject tag allows you to mix non-SVG content into your page. For example, you could drop some HTML in the middle of an SVG element.

这篇关于在SVG文本元素中插入HTML代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆