d3.select('body')
.append('svg')
.attr('width', 600)
.attr('height', 400)
.append('foreignObject')
.attr('width', 300)
.attr('height', 200)
.append('xhtml:div')
.attr('xmlns', 'http://www.w3.org/1999/xhtml')
.append('xhtml:input')
.attr('value', 5)
<foreignObject>SVG 元素允许包含不同的XML命名空间。属性:
height、width foreignObject 的宽高
x、y foreignObject 的x、y 坐标
具体详情查看 张鑫旭SVG<foreignObject>相关文档