How can I stop a ratioed image from appearing above the offcanvas menu?
Using Bootstrap 5, forcing the image to be 16x9...
<div class="ratio ratio-16x9 my-3">
<img width="768" height="432" src="my-image.jpg" class="object-fit-cover img-fluid w-100 wp-post-image" alt="" decoding="async" itemprop="image" sizes="(max-width: 768px) 100vw, 768px">
</div>
... causes the image to appear over my offcanvas menu...
<div class="offcanvas-md offcanvas-end sticky-md-top show" tabindex="-1" id="offcanvasResponsive"
aria-labelledby="offcanvasResponsiveLabel" aria-modal="true" role="dialog">
<div class="offcanvas-header border-bottom">
<h5 class="offcanvas-title " id="offcanvasResponsiveLabel">
<span id="site-title-offcanvas" itemprop="publisher" itemscope=""
itemtype="https://schema.org/Organization">
<a href="http://example.com/" title="My Site" rel="home" itemprop="url" class="navbar-brand"><span
itemprop="name">My Site</span></a> </span>
</h5>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#offcanvasResponsive"
aria-label="Close"></button>
</div>
<div class="offcanvas-body d-block vh-100 overflow-y-auto">
<nav role="navigation" itemscope="" itemtype="https://schema.org/SiteNavigationElement">
<ul class="list-unstyled m-3">
<li class="mb-2">
<a itemprop="url" data-bs-toggle="collapse" data-bs-target="#category-collapse" href="#"
class="nav-link sidebar-parent d-flex collapsed" aria-expanded="true">
<div class="flex-fill">
<i class="menu-icon fa-fw fa-solid fa-desktop"></i>
<span class="text" itemprop="name">Categories</span>
</div>
</a>
<!-- And more menu content -->
</nav>
</div>
</div>
It wasn't happening before I applied the ratios and, when I remove them, the ordering is fine.
.offcanvas-md
comes with z-index: var(--bs-offcanvas-zindex);
Varying this to any number (eg. 1050) and applying a low number (eg. z-index: 4
) to .ratio
does not result in the correct ordering.
Altering the position
value of the image also does not seem to work.