Didn’t find the answer you were looking for?
How do I adjust z-index using Bootstrap utilities to ensure my dropdown appears above a sticky header?
Asked on Dec 05, 2025
Answer
In Bootstrap 5, you can use utility classes to adjust the `z-index` of elements. To ensure a dropdown appears above a sticky header, you can use the `position-sticky` class for the header and adjust the `z-index` of both elements accordingly.
<!-- BEGIN COPY / PASTE -->
<header class="position-sticky top-0 bg-light z-1">
<!-- Sticky header content -->
Sticky Header
</header>
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown button
</button>
<ul class="dropdown-menu z-3" aria-labelledby="dropdownMenuButton">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</div>
<!-- END COPY / PASTE -->Additional Comment:
✅ Answered with Bootstrap 5 best practices.- The `position-sticky` class is used on the header to make it sticky.
- The `z-1` utility class sets a lower z-index for the header.
- The `z-3` utility class sets a higher z-index for the dropdown to ensure it appears above the header.
- Adjust the `z-index` values as needed using available Bootstrap utility classes (`z-0` to `z-3`).
Recommended Links:
