SVG - 获取TextElement的字体大小 [英] SVG - Get font-size of a TextElement

查看:272
本文介绍了SVG - 获取TextElement的字体大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果可以通过CSS设置和/或继承,可以获得SvgTextElement的字体大小?

How do I get the font size of a SvgTextElement when it could be set by CSS and/or inherited?

'getAttributeNS'仅在元素具有的情况下有效财产直接适用。
我认为它可能需要'baseVal',但我没有运气。

'getAttributeNS' only works if the Element has the property directly applied. I think it may require 'baseVal' but I'm having no luck.

浏览器:
IE + Adob​​e Svg Viewer
Firefox
Chrome
IE9

Browsers: IE + Adobe Svg Viewer Firefox Chrome IE9

推荐答案

var fontSize = window.getComputedStyle(element ,null).getPropertyValue(font-size);

其中element是document.getElementById或类似的结果。

where element would be the result of document.getElementById or something similar.

这篇关于SVG - 获取TextElement的字体大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆