How to display “Classic” built-up fractions with an horizontal line in CSS / JavaScript?

前端 未结 10 2267
旧巷少年郎
旧巷少年郎 2020-12-03 13:37

I have a fraction and I want to display it neatly and nicely.

For example

4/5

would be

4
-
5

I have looked at this and

10条回答
  •  情歌与酒
    2020-12-03 14:19

    .fraction {
      display: inline-block;
      position: relative;
      vertical-align: middle; 
      letter-spacing: 0.001em;
      text-align: center;
      font-size: 12px;
      }
    .fraction > span { 
      display: block; 
      padding: 0.1em; 
      }
    .fraction span.fdn {border-top: thin solid black;}
    .fraction span.bar {display: none;}
    Foobar
      
    4 / 5
    Foobar

    Change .fraction font-size to get it to a size you want

提交回复
热议问题