Open In App

How to use Diagonal Fractions in Tailwind CSS ?

Tailwind CSS diagonal-fractions utility allows you to display numbers separated by a slash as common diagonal fractions. This activates those sets of figures where the numerator and denominator appear small and are separated by a slash.

Syntax:

<element class="diagonal-fractions">  
Content
</element>

Diagonal-fractions Utility

The diagonal-fractions utility in Tailwind CSS helps in the creation of diagonal fractions. By applying this utility class, you can easily add a diagonal line to fractions, enhancing the visual representation of mathematical content.



Approach:

Example: Implementation to show how to use Fractions using Tailwind CSS.




<!doctype HTML>
<html>
  
<head>
    <title>Diagonal Fraction</title>
    <meta charset="UTF-8">
    <meta name="viewport" content=
          "width=device-width, initial-scale=1.0">
    <script src="https://cdn.tailwindcss.com"></script>
</head>
  
<body>
    <div class="min-h-screen flex items-center justify-center">
        <p class="text-3xl font-bold diagonal-fractions">
          1/2 2/3 3/4
          </p>
    </div>
</body>
  
</html>

Output:



Example 2: Implementation of Diagonal Fractions in Tailwind CSS.




<!DOCTYPE HTML>
<html>
  
<head>
    <title>Diagonal Fraction</title>
    <meta charset="UTF-8">
    <meta name="viewport" content=
          "width=device-width, initial-scale=1.0">
    <script src="https://cdn.tailwindcss.com"></script>
</head>
  
<body>
    <div class="min-h-screen flex items-center justify-center">
        <p>Using Normal Fractions: 1/2 2/3 3/4</p>
        <hr>
        <p class="text-3xl font-bold diagonal-fractions">
            Using Diagonal Fractions: 1/2 2/3 3/4
        </p>
    </div>
</body>
  
</html>

Output:


Article Tags :