VOOZH about

URL: https://www.geeksforgeeks.org/bootstrap/bootstrap-5-z-index/

⇱ Bootstrap 5 Z-index - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Bootstrap 5 Z-index

Last Updated : 7 May, 2024

In Bootstrap 5, the z-index property controls the stacking order of elements. It defines the depth of an element along the z-axis, determining which elements appear above others. Higher values place elements closer to the foreground, while lower values move them to the background.

Bootstrap 5 z-index classes:

ClassDescription
z-index-n2Represents z-index: -2
z-index-n1Represents z-index: -1
z-index-0Represents z-index: 0
z-index-1Represents z-index: 1
z-index-2Represents z-index: 2
z-index-3Represents z-index: 3

Syntax:

<div class="z-index-1 bg-primary position-absolute">
 ...
</div>

Example 1: Below example demonstrates the z-index-0, z-index-n2, and z-index-n1.

Output:

👁 Bootstrap-5-z-index
Bootstrap 5 Z-index Example Output

Example 2: Below example demonstrates the z-index-3, z-index-n2, and z-index-n1 classes.

Output:

👁 Bootstrap-5-z-index2
Bootstrap 5 Z-index Example Output
Comment

Explore