<mstyle>

<mstyle> MathML 元素用於更改其子元素的樣式。

注意:歷史上,此元素接受幾乎所有 MathML 屬性,並用於覆蓋其後代的預設屬性值。後來它被限制為僅幾個與現有網頁中使用的樣式屬性相關的屬性。如今,這些樣式屬性對所有 MathML 元素都是通用的,因此 <mstyle> 實際上等同於 <mrow> 元素。但是,<mstyle> 對於與瀏覽器之外的 MathML 實現的相容性仍然可能相關。

屬性

此元素的屬性包括全域性 MathML 屬性以及以下已棄用的屬性

background 已棄用 非標準

使用 background-color 代替。

color 已棄用 非標準

使用 color 代替。

fontsize 已棄用 非標準

使用 font-size 代替。

fontstyle 已棄用 非標準

使用 font-style 代替。

fontweight 已棄用 非標準

使用 font-weight 代替。

示例

對映到 CSS 的屬性

以下示例使用 全域性屬性 displaystylemathcolor 分別覆蓋 <munder><munderover> 子元素的 math-stylecolor

html
<math display="block">
  <mstyle displaystyle="false" mathcolor="teal">
    <munder>
      <mo></mo>
      <mi>I</mi>
    </munder>
    <munderover>
      <mo></mo>
      <mrow>
        <mi>i</mi>
        <mo>=</mo>
        <mn>1</mn>
      </mrow>
      <mi>N</mi>
    </munderover>
  </mstyle>
</math>

舊版指令碼屬性

以下示例顯示了一個公式,其中 font-size 設定為 128pt。它包含放置在巢狀上標中的數字,以及一個帶有舊版屬性 scriptsizemultiplierscriptminsize<mstyle> 元素。只要進入每個上標不會使字型大小小於 16ptfont-size 就會乘以 0.5

html
<math display="block" style="font-size: 128pt">
  <mstyle scriptsizemultiplier="0.5" scriptminsize="16pt">
    <msup>
      <mn>2</mn>
      <msup>
        <mn>2</mn>
        <msup>
          <mn>2</mn>
          <msup>
            <mn>2</mn>
            <msup>
              <mn>2</mn>
              <msup>
                <mn>2</mn>
                <mn>2</mn>
              </msup>
            </msup>
          </msup>
        </msup>
      </msup>
    </msup>
  </mstyle>
</math>

規範

規範
MathML Core
# style-change-mstyle

瀏覽器相容性

BCD 表格僅在啟用 JavaScript 的瀏覽器中載入。