Is it possible to append a div inside an SVG element?

前端 未结 3 441
日久生厌
日久生厌 2020-11-27 06:33

I am trying to append an HTML div inside an SVG, which I am trying to create a graph. I am trying to append it using the code below, but when I inspect element using Firebug

相关标签:
3条回答
  • 2020-11-27 07:10

    You are trying to append "rect" as well as "div" in the same line. Porbably that is where you are failing Check out these tutotials for D3... Its an amazing library based on SVG http://alignedleft.com/tutorials/d3/drawing-svgs/

    0 讨论(0)
  • 2020-11-27 07:28

    You can't append HTML to SVG (technically you can with foreignObject, but it's a rabbit hole). Furthermore, visible elements in SVG can't be nested, so elements such as circle, rect, path and such can't have children elements.

    0 讨论(0)
  • 2020-11-27 07:32

    I would also consider using <g> element as it serves similar purpose as <div> by grouping objects. More about it here.

    0 讨论(0)
提交回复
热议问题