Your code is functioning correctly. The issue lies in the visibility of the hamburger icon, which appears transparent without the .navbar-light
or .navbar-dark
classes. The solution is simple - add the .navbar-light
class to your .navbar
element to make the hamburger black and visible. Alternatively, you can use the .navbar-dark
class and apply a dark background color using .bg-dark
to achieve a white hamburger icon.
Additionally, using .navbar-expand-lg
means the hamburger will be displayed over the collapsed menu on screens smaller than the lg
breakpoint. The Bootstrap documentation explains responsive behaviors related to navbars:
...
.navbar-expand{-sm|-md|-lg|-xl|-xxl}
classes ... determine when their content collapses behind a button
...
For navbars that never collapse, add the .navbar-expand class on the navbar. For navbars that always collapse, don’t add any .navbar-expand class.
-- https://getbootstrap.com/docs/5.1/components/navbar/#responsive-behaviors
In the modified snippet below, I have included the .navbar-light
class in your code.
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b6d4d9d9c2c5c2c4d7c6f68398879885">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<nav class="navbar navbar-light navbar-expand-lg ">
<div class="container-fluid">
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-center" id="navbarNavAltMarkup">
<div class="navbar-nav">
<a class="nav-link active" aria-current="page" href="#">Home</a>
<a class="nav-link active" aria-current="page" href="#menu">Menu</a>
<a class="nav-link active" aria-current="page" href="#">Our Story</a>
<a class="nav-link active" aria-current="page" href="https://www.indeed.com/">Careers</a>
<a class="nav-link active" aria-current="page" href="#contact">Contact</a>
</div>
</div>
</div>
</nav>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d1b3bebea5a2a5a3b0a191e4ffe0ffe2">[email protected]</a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>