Tailwind CSS Z-index
The Tailwind z-{index} utility class allows you to control the stacking order of elements using the CSS z-index property.
Tailwind Z-index
The z-{index}
utility class in Tailwind CSS allows you to control the stacking order of elements using the CSS z-index property. With Tailwind's z-{index}
class, you can easily specify the z-index value for an element to determine its vertical position in the stacking order.
Applying Tailwind Z index
To apply a specific z-index value to an element, you can use the tailwind z-{index}
utility class, where {index}
represents the desired z-index value. The range of z-index values in Tailwind CSS goes from -1 to 50, with higher values bringing elements closer to the front.
Here's an example:
<div> <div class="z-5"> 5</div><div class="z-10"> 10</div><div class="z-20"> 20</div></div>
Preview
5
10
20
In the above example, a <div>
element is styled with the z-10 class, which sets the z-index value to 10.
Responsive Tailwind Z-index
Tailwind CSS allows you to apply z-index classes responsively at different breakpoints. To use responsive tailwind z index classes, you can append the breakpoint prefix to the utility class. For example, md:z-20 sets the z-index value to 20 starting from the medium breakpoint and above.
<div class="z-10 md:z-20"> This element has a z-index value of 10 by default, but starting from the medium breakpoint and above, it changes to 20.</div>
In the above example, the z-index of the <div>
element is set to 10 by default (z-10
), but starting from the medium breakpoint and above, it changes to 20 (md:z-20
).
Tailwind Z-index Class Table
Class | Properties |
---|---|
z-0 | z-index: 0; |
z-10 | z-index: 10; |
z-20 | z-index: 20; |
z-30 | z-index: 30; |
z-40 | z-index: 40; |
z-50 | z-index: 50; |
z-auto | z-index: auto; |
Windframe Tailwind blocks
Windframe is a drag and drop builder for rapidly building tailwind css websites and UIs