I'm updating a website design using Bootstrap and I want to create a navbar with a video playing in the background.
To ensure that the navbar stays fixed at the top while scrolling, I made it sticky.
After testing various methods, I managed to position the video behind the navbar by setting its position: absolute
.
However, a new issue arose when I tried adding more content after the navbar - everything appeared beneath the video instead of above it.
To resolve this problem, I removed the position: absolute
from the video and placed the navbar before the video element.
Despite my efforts, I've been unable to make it work correctly. Can someone with more experience in Bootstrap help me out?
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f0929f9f848384829180b0c5dec2dec3">[email protected]</a>/dist/css/bootstrap.min.css" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<!-- SECTION NAVBAR -->
<nav class="navbar navbar-expand-md sticky-top" style="background: none; transition: 1s;" id="navbar">
<div class="container-fluid">
<a class="navbar-brand" href="#">
<img src="https://via.placeholder.com/80" alt="Top Life" style="width: 40%; height: auto;">
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ul class="navbar-nav ms-auto">
<li class="nav-item">
<a class="nav-link" id="nav-link1" href="#">Servizi</a>
</li>
<li class="nav-item">
<a class="nav-link" id="nav-link2" href="#">Tecnologia</a>
</li>
<li class="nav-item">
<a class="nav-link" id="nav-link3" href="#">Immonbili</a>
</li>
<li class="nav-item">
<a class="nav-link" id="nav-link4" href="#">News</a>
</li>
<li class="nav-item">
<a class="nav-link" id="nav-link5" href="#">Identità </a>
</li>
<li class="nav-item">
<a class="nav-link" id="nav-link6" href="#">Contatti</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false" id="nav-link-dropdown">
<ion-icon name="globe-outline"></ion-icon>
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Italiano</a></li>
<li><a class="dropdown-item" href="#">English</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<!-- SECTION VIDEO -->
<video playsinline="playsinline" autoplay="autoplay" muted="muted" loop="loop">
<source src="/img/0314_compressed.mp4" type="video/mp4">
</video>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="22404d4d56515650435262170c100c11">[email protected]</a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7L+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
The desired outcome should resemble something like the image linked below: