gpt4 book ai didi

javascript - SVG - 获取 TextElement 的字体大小

转载 作者:行者123 更新时间:2023-11-30 08:11:41 26 4
gpt4 key购买 nike

当 SvgTextElement 可以通过 CSS 设置和/或继承时,如何获取它的字体大小?

'getAttributeNS' 仅在元素具有直接应用的属性时才有效。我认为它可能需要“baseVal”,但我运气不好。

浏览器:IE + Adob​​e Svg 查看器火狐 Chrome IE9

最佳答案

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

其中元素将是 document.getElementById 或类似内容的结果。

关于javascript - SVG - 获取 TextElement 的字体大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9485626/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com