Tailwind CSS Opacity

This class accepts a lot of value, and all of the properties are covered in class form. We can change the opacity of any element by using this class. The CSS Opacity attribute is used to do this.

Opacity Class

  • opacity-0: Control the opacity of an element with opacity-0.

Note: The opacity number can be changed from 0 to 100 with a span of 5.

Syntax is:

<element class="opacity-{number}">...</element>

Example

Code is as follows:

<!DOCTYPE html>
<html>
<head>
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
        rel="stylesheet">
</head>
<body class="text-center mx-4 space-y-2">
    <h1 class="text-red-600 text-5xl font-bold">
        Tutorial and Example
    </h1>
    <b>Opacity Class - Tailwind CSS </b>
    <div class="grid grid-flow-col text-center p-2">
        <div class="opacity-100  w-24 h-24 bg-red-500
                    rounded-lg">opacity-100
        </div>
        <div class="opacity-75 w-24 h-24 bg-red-500
                    rounded-lg">opacity-75
        </div>
        <div class="opacity-50 w-24 h-24 bg-red-500
                    rounded-lg">opacity-50
        </div>
        <div class="opacity-25 w-24 h-24 bg-red-500
                    rounded-lg">opacity-25
        </div>
        <div class="opacity-0  w-24 h-24 bg-red-500
                    rounded-lg">opacity-0
        </div>
    </div>
</body>
</html>

Output:

Tailwind CSS Opacity