我应该如何在 HTML 中表达像 15/16ths 这样的分数?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/173332/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-28 22:28:38  来源:igfitidea点击:

How should I express fractions like 15/16ths in HTML?

html

提问by raldi

I know there are HTML entities for 1/2, 1/4, and 3/4, but are there others? Like 1/3 or 1/8? Is there a good way to encode arbitrary fractions?

我知道有 1/2、1/4 和 3/4 的 HTML 实体,但还有其他的吗?像 1/3 还是 1/8?有没有一种对任意分数进行编码的好方法?

回答by Henrik Paul

how about 1516? (<sup>15</sup>&frasl;<sub>16</sub>)

怎么样15/ 16个?(<sup>15</sup>⁄<sub>16</sub>)

回答by scronide

1/2 → &#189; or &frac12;
1/4 → &#188; or &frac14;
3/4 → &#190; or &frac34;
1/8 → &#8539; or &frac18;
3/8 → &#8540; or &frac38;
5/8 → &#8541; or &frac58;
7/8 → &#8542; or &frac78;
1/3 → &#8531;
2/3 → &#8532;
1/5 → &#8533;
2/5 → &#8534;
3/5 → &#8535;
4/5 → &#8536;
1/6 → &#8537;
5/6 → &#8538;

...but you could also encode them as decimals: 15/16 = 0.9375 ;)

...但您也可以将它们编码为小数:15/16 = 0.9375 ;)

回答by tzot

For the existing fractions as Unicode codepoints (which are mapped to by HTML entities), search for "vulgar fraction" in the Unicode Character Names Index.

对于作为 Unicode 代码点的现有分数(由 HTML 实体映射到),请在Unicode 字符名称索引 中搜索“粗俗分数” 。

Now, for generic fractions, which work in HTML but also work in plain text, use the super- and subscript digits (see Unicode Codepoint Chart, search for "Superscripts") separated by the fraction slashcharacter.

现在,对于可以在 HTML 中使用但也可以在纯文本中使用的通用分数,请使用由分数斜线字符分隔的上标和下标数字(请参阅Unicode 代码点图表,搜索“上标”)。

Your example implemented as above:

您的示例实现如上:

1????

1??

回答by Aleksi Yrttiaho

For more complex scenarios there is also MathML. The support for this is slowly getting better. Internet Explorer seems to lag behind with this as well.

对于更复杂的场景,还有MathML。对此的支持正在慢慢好转。Internet Explorer 似乎也落后于此。

回答by Darryl Hein

Isn't just 15/16ths alright? Or even 15/16ths(15/16<sup>ths</sup>)?

不是只有15/16ths好吗?甚至 15/16 ths( 15/16<sup>ths</sup>)?

回答by epeleg

This would depend on your exact needs and audience. For most purposes many methods would be appropriate. 15/16, 15 parts of 16, 93.75%, 15/16all mean the same, you might even use symbols like ++++++++++++++-

这将取决于您的确切需求和受众。对于大多数目的,许多方法都是合适的。15/16, 16 的 15 部分, 93.75%, 15/ 16 的意思都一样,你甚至可以使用像 ++++++++++++++- 这样的符号

For some more complex scenarios you will need more complex solutions more like LaTeX than html. I believe there are also server side components that take LaTeX descriptions and create images that are browser compatible, such as described here: http://www.fauskes.net/nb/htmleqII/

对于一些更复杂的场景,您将需要更复杂的解决方案,比如 LaTeX 而不是 html。我相信还有服务器端组件采用 LaTeX 描述并创建与浏览器兼容的图像,例如此处所述:http: //www.fauskes.net/nb/htmleqII/

回答by Marcin Gil

There is also a standard called MathML. But is for XML unfortunately. However if you have more expressions you might consider switching to basic XML.

还有一个标准叫做MathML。但不幸的是对于 XML。但是,如果您有更多的表达式,您可能会考虑切换到基本的 XML。