<mpadded>

Baseline 2023 *
Newly available

Since January 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

* Some parts of this feature may have varying levels of support.

<mpadded> MathML 元素用于添加额外的内边距,并设置封闭内容的位置和大小的一般调整。

属性

该元素的属性包括全局 MathML 属性以及以下属性:

depth

一个 <length-percentage>,指示 <mpadded> 元素的期望深度(基线以下)。

height

一个 <length-percentage>,指示 <mpadded> 元素的期望高度(基线以上)。

lspace

一个 <length-percentage>,指示子内容的定位点相对于 <mpadded> 元素的定位点的水平位置。

voffset

一个 <length-percentage>,指示子内容的定位点相对于 <mpadded> 元素的定位点的垂直位置。

width

一个 <length-percentage>,指示 <mpadded> 元素的期望水平长度。

旧版语法

对于 depthheightlspacevoffsetwidth 属性,一些浏览器可能接受更复杂的语法:

  1. 可选的 +- 符号作为前缀,指定对应维度的增量或减量(如果缺失,则对应维度直接设置为指定值)。
  2. 后跟一个 <unsigned-number>(下面称为 α)。
  3. 可选地跟随一个值(如果缺失,则指定值被解释为“α 的百分比的 100 倍”)。
    • 一个单位。指定值的解释方式与旧版 MathML 长度相同。
    • 一个命名空间常量。指定值被解释为 α 乘以常量。
    • 一个伪单位 widthheightdepth。指定值被解释为内容的对应维度的 α 倍。
    • 一个百分号后跟伪单位 widthheightdepth。指定值被解释为内容的对应维度的 α%。

示例

尺寸和偏移

html
<math display="block">
  <mpadded width="400px" height="5em" depth="4em"
           lspace="300px" voffset="-2em"
           style="background: lightblue">
    <mi>x</mi>
    <mo>+</mo>
    <mi>y</mi>
  </mpadded>
</math>

旧版语法

html
<math display="block">
  <!-- 增加一定的长度 -->
  <mpadded width="+20px" style="background: lightblue">
    <mtext>+20px</mtext>
  </mpadded>

  <!-- 设定为伪单位 -->
  <mpadded width="2width" style="background: lightgreen">
    <mtext>2width</mtext>
  </mpadded>

  <!-- 以伪单位的百分比增加 -->
  <mpadded width="+400%height" style="background: lightyellow">
    <mtext>+400%height</mtext>
  </mpadded>

  <!-- 递减至命名空间的倍数 -->
  <mpadded width="-1thickmathspace" style="background: pink">
    <mtext>-.5thickmathspace</mtext>
  </mpadded>
</math>

规范

Specification
MathML Core
# adjust-space-around-content-mpadded

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
mpadded
depth
height
lspace
Named spaces (e.g. thinmathspace to mean 3/18em)
DeprecatedNon-standard
Nonzero unitless values (e.g. 5 to mean 500%)
DeprecatedNon-standard
Pseudo units (e.g. width to mean content width)
DeprecatedNon-standard
Relative values (e.g. "+10px")
Non-standard
<unsigned-number> as a scale factor or percent
DeprecatedNon-standard
voffset
width

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Non-standard. Check cross-browser support before using.
Deprecated. Not for use in new websites.

参见