SVGTextContentElement: lengthAdjust 属性

Baseline 已广泛支持

此特性已相当成熟,可在许多设备和浏览器版本上使用。自 ⁨2015 年 7 月⁩以来,各浏览器均已提供此特性。

SVGTextContentElement 接口的只读属性 lengthAdjust 反映了给定元素的 lengthAdjust 属性。它接受该接口上定义的 LENGTHADJUST_* 常量之一。

一个 SVGAnimatedEnumeration

示例

访问 lengthAdjust 属性

html
<svg width="200" height="100">
  <text id="myText" x="10" y="50" textLength="100" lengthAdjust="spacing">
    Hello, SVG!
  </text>
</svg>
js
const textElement = document.getElementById("myText");

// Access the `lengthAdjust` property
const lengthAdjust = textElement.lengthAdjust;

// Log the base value of the `lengthAdjust` attribute
console.log(lengthAdjust.baseVal); // Output: 1 (e.g. LENGTHADJUST_SPACING)

规范

规范
Scalable Vector Graphics (SVG) 2
# __svg__SVGTextContentElement__lengthAdjust

浏览器兼容性

另见