×

Tailwind CSS Z-index

The tailwind CSS framework is a CSS utility framework that provides classes for managing HTML content with CSS. Tailwind CSS simplifies our design process and makes it responsive across numerous platforms. The z-Index utility is used to control an element's stack order. It's a replacement for the CSS z-index property. As seen in the examples below, this class is used to describe the z-index along the three-dimensional plane.

Tailwind CSS z-index classes

The Tailwind CSS z-index classes are as follows:

  • z-0
  • z-10
  • z-20
  • z-30
  • z-40
  • z-50
  • z-auto

Note: In the abovementioned class, z-0 is the same as the CSS property z-index:0 and so on.

z-0

It is used to give the element a z-index of zero.

Syntax

<element class="z-0">....</element>

Example:

<!DOCTYPE html>
<head>
    <link
    rel="stylesheet"
    href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css">
</head>
<body class="text-center">
    <h1 class="text-red-600 text-5xl font-bold">
        Tutorial and Example
    </h1>
    <b>Z-Index Class - Tailwind CSS </b>
    <div class="flex-column">
        <div class="relative z-0 w-full
                    h-12 bg-red-400"
              style="top: 32px;">0</div>
        <div class="relative z-10 w-full
                    h-12 bg-blue-400">1</div>
        <div class="relative z-20 w-full
                    h-12 bg-yellow-400">2</div>
        <div class="relative z-30 w-full
                    h-12 bg-purple-400">3</div>
        <div class="relative z-40 w-full
                    h-12 bg-green-300">4</div>
        <div class="relative z-50 w-full
                    h-12 bg-gray-400">5</div>
    </div>
</body>
  </html>

Output:

Tailwind CSS Z-index

z-10

It is used to give the element a z-index 10. Along the z-axis, the items seem 10px upside down.

Syntax

<element class="z-10">....</element>

Example:

<!DOCTYPE html>
<head>
    <link
    rel="stylesheet"
    href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css">
</head>
<body class="text-center">
    <h1 class="text-red-600 text-5xl font-bold">
        Tutorial and Example
    </h1>
    <b>Z-Index Class - Tailwind CSS </b>
    <div class="flex-column">
        <div class="relative z-0 w-full
                    h-12 bg-red-400" >0</div>
        <div class="relative z-10 w-full
                    h-12 bg-blue-400" style="top: 32px;">1</div>
        <div class="relative z-20 w-full
                    h-12 bg-yellow-400">2</div>
        <div class="relative z-30 w-full
                    h-12 bg-purple-400">3</div>
        <div class="relative z-40 w-full
                    h-12 bg-green-300">4</div>
        <div class="relative z-50 w-full
                    h-12 bg-gray-400">5</div>
    </div>
</body>
 </html>

Output:

Tailwind CSS Z-index

z-20

It is used to give the element a z-index of 20. Along the z-axis, the items are 20px upside down.

Syntax

<element class="z-20">....</element>

Example:

<!DOCTYPE html>
<head>
    <link
    rel="stylesheet"
    href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css">
</head>
<body class="text-center">
    <h1 class="text-red-600 text-5xl font-bold">
        Tutorial and Example
    </h1>
    <b>Z-Index Class - Tailwind CSS </b>
    <div class="flex-column">
        <div class="relative z-0 w-full
                    h-12 bg-red-400" >0</div>
        <div class="relative z-10 w-full
                    h-12 bg-blue-400">1</div>
        <div class="relative z-20 w-full
                    h-12 bg-yellow-400" style="top: 32px;">2</div>
        <div class="relative z-30 w-full
                    h-12 bg-purple-400">3</div>
        <div class="relative z-40 w-full
                    h-12 bg-green-300">4</div>
        <div class="relative z-50 w-full
                    h-12 bg-gray-400">5</div>
    </div>
</body>
 </html>

Output:

Tailwind CSS Z-index

z-30

It is used to give the element a z-index of 30. Along the z-axis, the items are 30px upside down.

Syntax

<element class="z-30">....</element>

Example:

<!DOCTYPE html>
<head>
    <link
    rel="stylesheet"
    href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css">
</head>
<body class="text-center">
    <h1 class="text-red-600 text-5xl font-bold">
       Tutorial and Example
    </h1>
    <b>Z-Index Class - Tailwind CSS </b>
    <div class="flex-column">
        <div class="relative z-0 w-full
                    h-12 bg-red-400" >0</div>
        <div class="relative z-10 w-full
                    h-12 bg-blue-400">1</div>
        <div class="relative z-20 w-full
                    h-12 bg-yellow-400">2</div>
        <div class="relative z-30 w-full
                    h-12 bg-purple-400" style="top: 32px;">3</div>
        <div class="relative z-40 w-full
                    h-12 bg-green-300">4</div>
        <div class="relative z-50 w-full
                    h-12 bg-gray-400">5</div>
    </div>
</body>
</html>

Output:

Tailwind CSS Z-index

z-40

It is used to give the element a z-index of 40. Along the z-axis, the elements are 40px upside down.

Syntax

<element class="z-40">....</element>

z-50

It is used to give the element a z-index of 50. Along the z-axis, the elements are 50px upside down.

Syntax

<element class="z-50">....</element>

Related Topics

Tailwind CSS Clear

This class acknowledges more than one worth in tailwind CSS. Every one of the properties is canvassed as in class form. It is an option in contrast to the CSS...

5 minutes read.

Tailwind CSS Display

It acknowledges more than one worth in tailwind CSS. Every one of the properties is shrouded as in class structure. It is an option in contrast to the CSS display...

5 minutes read.

Tailwind CSS Top / Right / Bottom / Left

In tailwind CSS, these classes take a variety of values and cover all of the characteristics in the class form. These are the CSS Top/Right/Bottom/Left properties' replacements. These classes are...

4 minutes read.

Tailwind CSS Width

The tailwind CSS width class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS Width Property. This...

3 minutes read.

Tailwind CSS tutorial

Tailwind CSS can be utilized to make sites in the quickest and the least demanding way. Tailwind CSS is the most famous utility-first CSS structure on the planet for quickly...

4 minutes read.

Tailwind CSS Container

In Tailwind CSS, a compartment is utilized to fix the maximum width (max-width) of a component to match the min-width of the breakpoint. It comes exceptionally convenient when content must...

2 minutes read.

Tailwind CSS Place Content

This class accepts a wide range of values. It's a replacement for the CSS Place Content property. This class is used to manage how information is justified while still being...

5 minutes read.

Tailwind CSS Place Self

The tailwind CSS Place self class accepts a wide range of values. It's a replacement for the CSS Place Items property. This class is used to manage how a single...

4 minutes read.

Tailwind CSS Visibility

In tailwind CSS, this class accepts two values. It's a replacement for the CSS visibility property. This class specifies whether an element in a web document is visible or not,...

2 minutes read.

Tailwind CSS Object Position

It acknowledges more than one value in tailwind CSS. Every one of the properties is covered as in class form. It is the option in contrast to the CSS object-position...

2 minutes read.

Tailwind CSS Stroke

This class accepts a lot of value, and all of the properties are covered in class form. It's the stroke class that goes on top of the SVG element. Stroke...

2 minutes read.

Tailwind CSS Order

One of the best features of Tailwind CSS is the Order class, which allows us to order flex and grid objects according to our needs. There are several different order...

2 minutes read.

Tailwind CSS Flex Direction

CSS flexbox is an important element for frontend development. CSS has four directions, therefore in tailwind CSS, all of the properties are covered in class form. It's a front-end development...

5 minutes read.

Tailwind CSS Align Self

This class accepts a wide range of values. It's a replacement for the CSS Align Self attribute. This class is used to control how a flex or grid item is...

4 minutes read.

Tailwind CSS Margin

The margin class accepts a large number of values, and all of the properties are covered in the same way they are in the class form. It's a replacement for...

6 minutes read.

Tailwind CSS Space Between

In tailwind CSS, this class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS Space Between property....

4 minutes read.

Tailwind CSS Position

The position class acknowledges more than one value in tailwind CSS. It is an option in contrast to the CSS Position property. This class is utilized for controlling how an...

5 minutes read.

Tailwind CSS Grid Template Columns

In tailwind CSS, this class accepts multiple values, and all of the properties are covered in class form. It's the CSS grid-template-columns property's replacement. It's used to specify the number...

2 minutes read.

Tailwind CSS Flex Grow

CSS flexbox is an important element for frontend development; there are two flex-grow options in Tailwind CSS, and all attributes are covered in class form. It is an alternative to...

3 minutes read.

Tailwind CSS Min-Width

In tailwind CSS, this class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS min-width property. This...

1 minute read.