math-shift

可用性有限

此特性不是基線特性,因為它在一些最廣泛使用的瀏覽器中不起作用。

實驗性: 這是一項實驗性技術
在生產中使用此技術之前,請仔細檢查瀏覽器相容性表格

math-shift 屬性指示 MathML 公式中的上標是按正常偏移還是緊湊偏移提升。

語法

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

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

normal

初始值表示正常渲染。MathML 公式中的上標使用 OpenType MATH 表中的 superscriptShiftUp 引數。

compact

表示緊湊渲染。MathML 公式中的上標使用 OpenType MATH 表中的 superscriptShiftUpCramped 引數,該引數通常更小。

正式定義

初始值normal
應用於所有元素
繼承性
計算值同指定值
動畫型別不可動畫化

正式語法

math-shift = 
normal |
compact
此語法反映了 MathML Core 的最新標準。並非所有瀏覽器都可能已實現所有部分。請參閱瀏覽器相容性以獲取支援資訊。

示例

CSS

css
math {
  math-shift: compact;
  font-size: 64pt;
}

.normal-shift {
  math-shift: normal;
}
.compact-shift {
  math-shift: compact;
}

MathML

以下 MathML 使用帶有 OpenType MATH 表的字型顯示了“x 平方”的兩個版本。實現了 math-shift 屬性的瀏覽器應該使用略微不同的偏移來提升上標。

html
<math>
  <msup class="normal-shift">
    <mi>x</mi>
    <mn>2</mn>
  </msup>
  <msup class="compact-shift">
    <mi>x</mi>
    <mn>2</mn>
  </msup>
</math>

規範

規範
MathML Core
# the-math-shift

瀏覽器相容性

另見