【发布时间】:2010-12-16 11:31:37
【问题描述】:
我正在尝试让 SVG 'text' 元素适合 svg 'rect' 元素。例如在下面的示例中,我使用了 5 个字符的等宽文本,字体大小为 100px,并且我希望在文本附近有一个边界矩形。
但文字右侧有一个空白。
<svg xmlns="http://www.w3.org/2000/svg" height="200" width="1000">
<text x="10px" y="110px" style="font-family:monospace;font-size:100px;">HELLO</text>
<rect x="10px" y="10px" width="500px" height="100px" style="stroke:blue;fill:none;"/>
</svg>
我应该为“文本”元素使用哪些 CSS 选择器?
注意:我不想使用 text-on-a-path 方法。只是一个固定大小的字体。
谢谢;
【问题讨论】:
标签: css fonts svg bounding-box