Reputation: 793
I'm trying to get the height of an SVG string. I'm getting the width with getComputedTextLength(), which works well, but there doesn't seem to be any equivalent for height.
getBBox() is not an option. It is no longer supported in Firefox, at least not for text, apparently because it is part of SVG 2.0.
Upvotes: 0
Views: 1082
Reputation: 16515
For any Element you can use getBoundingClientRect()
. have a look here for documentation. In some Browsers the returned rect does not have a height property, but by simple subtracting rect.bottom - rect.top
you got it.
Please not that getBoundingClientRect()
will return values in absolute space, whereby getBBox()
returns values in user space of the element, what can be confusing if it has applied transformations.
Upvotes: 2
Reputation: 101820
getBBox()
should work fine for text elements on Firefox.
This worked fine for me in FF 32.
Upvotes: 2