Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying diagonal fractions in HTML

Tags:

html

css

I had followed many of the posts in StackOverflow, but they talk about stacked fractions.
I was working on displaying diagonal fractions like this:
enter image description here
Here is my code :

* {
  font-size: 50px;
}

.container {
  display: inline-grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  border: 1px solid red;
}

.numerator {
  grid-column: 1/2;
  grid-row: 1/2;
  border: 1px solid green;
}

.denominator {
  grid-column: 2/3;
  grid-row: 2/3;
  border: 1px solid green;
}
<span class="container"><span class="numerator">3</span><span class="denominator">5</span></span><br><br>
<span class="container"><span class="numerator">17</span><span class="denominator">4113</span></span>

Note: I have added borders just for clarity.

But, I cannot figure out how to add that slash in between. Please help.

like image 320
Puspam Avatar asked Jan 17 '26 08:01

Puspam


1 Answers

One simple way is to just use the subscript tag, and the superscript tag.

<p>This text contains <sup>23</sup>/<sub>24</sub> of a number</p>

This text contains 23/24 of a number

like image 77
R. Gabriel Avatar answered Jan 20 '26 03:01

R. Gabriel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!