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

瀏覽器相容性

另見