Simulating contenteditable in SVG without foreignobject

后端 未结 1 436
深忆病人
深忆病人 2021-02-05 10:16

I have written a web-application where users can create svg elements with text. I want to simulate contenteditable elements inside the svg elements, so that users can dynamicall

相关标签:
1条回答
  • 2021-02-05 10:25

    Here's an example:

    <div contenteditable="true">
        <svg>
            <circle cx="10" cy="10" r="5" fill="green" />
            <text y="2em">Hello world</text>
        </svg>
    </div>
    

    http://jsfiddle.net/ZEAwB/

    Works in Opera 18, Chrome 33, Firefox (Nightly) 28 and IE9. Probably works in earlier versions of Opera, Chrome and Firefox too, not quite sure how far back though.

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