gpt4 book ai didi

dom - 如何在 svg 中嵌入 HTML div

转载 作者:行者123 更新时间:2023-12-04 14:15:20 30 4
gpt4 key购买 nike

例子:

<div> Hello World </div>

<svg>
<div> From SVG Land</div>
</svg>

题:

尽管有标签,SVG 对象是否被单独解析而不是 dom 树的某个适当部分?如何在 SVG 元素中获取 DIV?

最佳答案

正如@Stasik 所提到的,可以使用foreignObject。

例子:

<svg>
<foreignObject width="100" height="50"
requiredExtensions="http://www.w3.org/1999/xhtml">
<!-- XHTML content goes here -->
<body xmlns="http://www.w3.org/1999/xhtml">
<p>Here is a paragraph that requires word wrap</p>
</body>
</foreignObject>
<svg>

摘自: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/foreignObject

关于dom - 如何在 svg 中嵌入 HTML div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11382369/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com