SVG get text element width

前端 未结 6 1824
误落风尘
误落风尘 2020-12-02 07:40

I\'m working on some ECMAScript/JavaScript for an SVG file and need to get the width and height of a text element so I can resize a re

6条回答
  •  误落风尘
    2020-12-02 08:16

    var bbox = textElement.getBBox();
    var width = bbox.width;
    var height = bbox.height;
    

    and then set the rect's attributes accordingly.

    Link: getBBox() in the SVG v1.1 standard.

提交回复
热议问题