如何在html中表示分数 [英] How to represent fractions in html

查看:1615
本文介绍了如何在html中表示分数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

 < sup> 3< /坐席>&安培; frasl;<副> 8 LT; /子> 

它看起来像这样:



但是我想表现得像这样:



我该如何改变它?



需要一些指导。

解决方案

这不可能通过纯HTML。但您可以使用一些CSS来创建这种类型的分数。



  .fraction {position:relative;宽度:1em; font-size:2em;}。numerator {border-bottom:2px solid black; text-align:center;}。分母{border-right:2px纯黑色;宽度:0.75em; text-align:center;}  

< div class = 分数 > < div class =numerator> 3< / div> < div class =denominator> 8< / div>< / div>

I want to represent fractions in html and the code I am using now is this:

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

And it looks like this:

But I want to represent it something like this:

How do I change it?

Need some guidance on this.

解决方案

It is not possible through pure HTML. But you can create that type of fraction using a bit of CSS.

.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;
}

<div class="fraction">
  <div class="numerator">3</div>
  <div class="denominator">8</div>
</div>

这篇关于如何在html中表示分数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆