<mfrac>
Baseline 2023Newly available
Since January 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
语法
html
<mfrac>numerator denominator</mfrac>
属性
这个元素的属性包括全局 MathML 属性以及以下属性:
denomalign
已弃用 非标准-
分数下的分母对齐方式。可能的值包括:
left
、center
(默认)和right
。 linethickness
-
指示水平分数线的粗细的
<length-percentage>
。 numalign
已弃用 非标准-
分数上的分子对齐方式。可能的值包括:
left
、center
(默认)和right
。
备注:
对于 linethickness
属性,一些浏览器可能还接受不推荐使用的值 medium
、thin
和 thick
(其确切解释留给实现者)或旧版 MathML 长度。
示例
简单分数
以下 MathML 代码应该渲染为分子是“a + 2”,分母是“3 − b”的分数:
html
<math display="block">
<mfrac>
<mrow>
<mi>a</mi>
<mo>+</mo>
<mn>2</mn>
</mrow>
<mrow>
<mn>3</mn>
<mo>−</mo>
<mi>b</mi>
</mrow>
</mfrac>
</math>
无分数线的分数
以下 MathML 代码应该渲染为二项式系数:
html
<math display="block">
<mrow>
<mo>(</mo>
<mfrac linethickness="0">
<mi>n</mi>
<mi>k</mi>
</mfrac>
<mo>)</mo>
</mrow>
</math>
规范
Specification |
---|
MathML Core # fractions-mfrac |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
mfrac | ||||||||||||
denomalign | ||||||||||||
linethickness | ||||||||||||
Named spaces (e.g. thinmathspace to mean 3/18em) | ||||||||||||
Nonzero unitless values (e.g. 5 to mean 500% the default thickness) | ||||||||||||
thin , medium , thick values | ||||||||||||
numalign |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Partial support
- Partial support
- No support
- No support
- Non-standard. Check cross-browser support before using.
- Deprecated. Not for use in new websites.
- Has more compatibility info.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.