如何在html中表示分数

时间:2015-08-02 16:06:57

标签: html fractions

我想在html中表示分数,而我现在使用的代码是:

<sup>3</sup>&frasl;<sub>8</sub>

它看起来像这样:

enter image description here

但我想代表这样的事情:

enter image description here

如何更改?

需要一些指导。

2 个答案:

答案 0 :(得分:1)

通过纯HTML无法实现。但是你可以使用一些CSS创建那种类型的分数。

&#13;
&#13;
.fraction {
  position: relative;
  width: 1em;
  font-size: 2em;
}
.numerator {
  border-bottom: 2px solid black;
  text-align: center;
}
.denominator {
  border-right: 2px solid black;
  width: 0.75em;
  text-align: center;
}
&#13;
<div class="fraction">
  <div class="numerator">3</div>
  <div class="denominator">8</div>
</div>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

您可以使用mathjax。它是数学渲染的事实库。但是,它不轻巧。请注意,谷歌选择来支持mathml

或者,使用html / css。一小部分只是两个堆叠在一起的div,中间有一个边框。