math-depth

可用性有限

此特性不是基线特性,因为它在一些最广泛使用的浏览器中不起作用。

math-depth 属性描述了数学公式中每个元素相对于该公式顶层容器的“深度”概念。当应用 font-size: math 时,它用于缩放元素的 font-size 的计算值。

注意:在 MathML Core 用户代理样式表中,font-size: math<math> 元素的默认值,因此无需明确指定。

语法

css
/* Keyword values */
math-depth: auto-add;

/* Relative values */
math-depth: add(2);
math-depth: add(-2);

/* Absolute value */
math-depth: 4;

/* Global values */
math-depth: inherit;
math-depth: initial;
math-depth: revert;
math-depth: revert-layer;
math-depth: unset;

auto-add

当继承的 math-stylecompact 时,设置为继承的 math-depth 加 1。

add(<integer>)

设置为继承的 math-depth 加指定的整数。

<integer>

设置为指定的整数。

正式定义

初始值0
应用于所有元素
继承性
计算值同指定值
动画类型不可动画化

正式语法

math-depth = 
auto-add |
add( <integer> ) |
<integer>
此语法反映了 MathML Core 的最新标准。并非所有浏览器都可能已实现所有部分。请参阅浏览器兼容性以获取支持信息。

示例

指定数学深度

以下示例显示了更改 math-depth 属性对子公式字体大小的影响。每个子公式中的数字表示应用的 math-depth 和缩放因子。

第一个 <mtext> 元素用作其他子公式的参考,没有应用特定的样式。第二个和第三个子公式将 math-depth 设置为 auto-add,并显示根据 math-style 进行缩放的效果。

最后两个子公式显示了将 math-depth 设置为特定值的效果。

HTML

html
<p>
  <math>
    <mtext>0</mtext>

    <!-- auto-add value has no effect when math-style is normal -->
    <mrow style="math-style: normal">
      <mrow style="math-depth: auto-add">
        <mtext>0</mtext>
      </mrow>
    </mrow>

    <!-- the inherited math-style is compact, so math-depth is set to 1 -->
    <mrow style="math-depth: auto-add">
      <mtext>1</mtext>
    </mrow>

    <mrow style="math-depth: add(2)">
      <mtext>2</mtext>
      <mrow style="math-depth: add(-1)">
        <mtext>1</mtext>
      </mrow>
      <mrow style="math-depth: 0">
        <mtext>0</mtext>
      </mrow>
    </mrow>
  </math>
</p>

结果

规范

规范
MathML Core
# the-math-script-level-property

浏览器兼容性

另见