我肯定遗漏了一些明显的东西,但我无法获得 <text>
现身。参见 http://jsfiddle.net/ydaLh/用于 HTML + CSS
<svg style="width: 320px; height: 200px; top: 0px; left: 0px; position: relative;">
<g class="depth">
<g class="children">
<rect class="child" x="99" y="0" width="47" height="30">
<text dy=".75em" x="105" y="6">PRIMARY</text>
</rect>
<rect class="child" x="90" y="0" width="8" height="30">
<text dy=".75em" x="96" y="6">MASTER</text>
</rect>
<rect class="parent" x="90" y="0" width="56" height="30"></rect>
</g>
</g>
</svg>
最佳答案
在 SVG 中,你不会在图形元素中嵌套文本元素,你必须有类似的东西:
svg
.append("rect")
.append("text");
但你实际上需要:
svg.append("rect");
svg.append("text");
关于css - 为什么svg是:text just not displaying?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14970504/