Z-Index
Z-Index
Canvas provides a compact z-index scale for layering elements, extending Bootstrap's small set.
Z-index classes
| Class | z-index |
|---|---|
.z-n1 |
-1 (send behind) |
.z-0 |
0 |
.z-1 |
1 |
.z-2 |
2 |
.z-3 |
3 |
.z-4 |
4 |
.z-5 |
5 |
.z-6 |
6 |
.z-7 |
7 |
.z-8 |
8 |
.z-9 |
9 |
.z-10 |
10 |
.z-auto |
auto |
All are marked !important so they reliably override component defaults. Z-index only takes effect on positioned elements, so pair these with .position-relative, .position-absolute, .position-fixed, or .position-sticky.
Usage
Layer an overlay above an image but keep text on top of both:
<div class="position-relative">
<img src="photo.jpg" class="z-0" alt="">
<div class="position-absolute top-0 start-0 w-100 h-100 bg-dark opacity-50 z-1"></div>
<div class="position-absolute top-50 start-50 translate-middle z-2 text-white">
Caption above the overlay
</div>
</div>Push a decorative shape behind content:
<div class="position-absolute z-n1">Decorative background shape</div>Classes
| Class | Description |
|---|---|
.z-* | Sets the
Example: [ch_pre]
...
...
|
Was this page helpful?
