此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

<mpadded>

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2023年1月⁩.

* 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

浏览器兼容性

参见