math-style

Baseline 2023
新推出

自 2023 年 8 月起,此功能已在最新的设备和浏览器版本中可用。此功能可能不适用于旧设备或浏览器。

math-style 属性指示 MathML 方程式是应以正常高度还是紧凑高度渲染。

语法

css
/* Keyword values */
math-style: normal;
math-style: compact;

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

normal

初始值表示正常渲染。

compact

后代元素的数学布局会尝试最小化逻辑高度。

正式定义

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

正式语法

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

示例

将公式的样式更改为紧凑型

CSS

css
math {
  math-style: normal;
}
.compact {
  math-style: compact;
}

HTML

html
<p>
  Normal height
  <math>
    <mrow>
      <munderover>
        <mo>∑</mo>
        <mrow>
          <mi>n</mi>
          <mo>=</mo>
          <mn>1</mn>
        </mrow>
        <mrow>
          <mo>+</mo>
          <mn>∞</mn>
        </mrow>
      </munderover>
    </mrow>
  </math>
  and compact height
  <math class="compact">
    <mrow>
      <munderover>
        <mo>∑</mo>
        <mrow>
          <mi>n</mi>
          <mo>=</mo>
          <mn>1</mn>
        </mrow>
        <mrow>
          <mo>+</mo>
          <mn>∞</mn>
        </mrow>
      </munderover>
    </mrow>
  </math>
  equations.
</p>

结果

规范

规范
MathML Core
# the-math-style-property

浏览器兼容性

另见