此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

scriptlevel

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

scriptlevel 全局属性设置 MathML 元素的数学深度。它允许覆盖用户代理样式表中定义的在 MathML 公式中自动计算字体大小的规则。

示例

html
<!-- math-depth 在 <math> 根元素上默认为 0。 -->
<math style="font-size: 64pt">
  <msubsup>
    <!-- base 上的 math-depth 和 font-size 保持不变。 -->
    <mtext>BASE</mtext>
    <!-- math-depth 在下标中默认为 add(1),因此增加了 1,字体大小缩小了一次。 -->
    <mtext>SUBSCRIPT</mtext>
    <!-- 上标中的 math-depth 也默认为 add(1),但 scriptlevel 属性告诉它增加 2,因此实际上字体大小缩小了两次。 -->
    <mtext scriptlevel="+2">SUPERSCRIPT</mtext>
  </msubsup>
</math>

语法

html
<math scriptlevel="-1"> <!-- 将 math-depth 减小 1 -->
<math scriptlevel="+2"> <!-- 将 math-depth 增加 2 -->
<math scriptlevel="0"> <!-- 重置 math-depth 为 0 -->

如果 <U> 是一个无符号整数(即移除了前缀符号的整数),则接受的值为:

<U>

将 math-depth 设置为值 <U>。这将使元素的 font-size 与指定深度的元素的字体大小相同。

+<U>

math-depth 设置为值 add(<U>)。这将使元素的 font-size 缩小 <U> 次。

-<U>

math-depth 设置为值 add(-<U>)。这将使元素的 font-size 放大 <U> 次。

规范

Specification
MathML Core
# dfn-scriptlevel

浏览器兼容性

参见