This class accepts lots of value in tailwind CSS in which all the properties are covered in class form. By using this class we can set the opacity of any element. In CSS, we do that by using the CSS Opacity property.
Opacity class:
- opacity-0: Control the opacity of an element.
Note: The number of the opacity can be changeable from 0 to 100 with the span of 5.
Syntax:
<element class="opacity-{number}">...</element>
Example:
HTML
<!DOCTYPE html>
< html >
< head >
< link href =
rel = "stylesheet" >
</ head >
< body class = "text-center mx-4 space-y-2" >
< h1 class = "text-green-600 text-5xl font-bold" >
GeeksforGeeks
</ h1 >
< b >Tailwind CSS Opacity Class</ b >
< div class = "grid grid-flow-col text-center p-2" >
< div class="opacity-100 w-24 h-24 bg-green-500
rounded-lg">opacity-100
</ div >
< div class="opacity-75 w-24 h-24 bg-green-500
rounded-lg">opacity-75
</ div >
< div class="opacity-50 w-24 h-24 bg-green-500
rounded-lg">opacity-50
</ div >
< div class="opacity-25 w-24 h-24 bg-green-500
rounded-lg">opacity-25
</ div >
< div class="opacity-0 w-24 h-24 bg-green-500
rounded-lg">opacity-0
</ div >
</ div >
</ body >
</ html >
|
Output:

Tailwind CSS opacity class