I'm attempting to utilize Bootstrap to create active classes that display a nav-pill/container around the active section of my webpage. It works well on larger screens, but on smaller screens with the hamburger menu active, the nav-pill stretches across the entire div/container instead of wrapping only around the word, similar to how it appears on larger screens.
For a demonstration of the issue, you can visit this CodePen with filler content: https://codepen.io/100emoji/pen/mdxdpzp
Below is the code for the navigation bar:
<!-- Bootstrap-5 -->
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f3919c9c878087819283b3c6ddc2ddc0">[email protected]</a>/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="aac8c5c5ded9ded8cbdaea9f849b8499">[email protected]</a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<!-- Body -->
<body data-bs-spy="scroll" data-bs-target="#navbar" data-bs-offset="400" data-bs-smooth-scroll="true">
<!-- Navigation Bar-->
<nav id="navbar" class="navbar navbar-expand-md bg-dark navbar-dark py-3 sticky-top">
<div class="container">
<a href="#" class="navbar-brand">Ken's Art & Frame</a>
<button class="navbar-toggler collapsed d-flex d-md-none flex-column justify-content-around" type="button" data-bs-toggle="collapse" data-bs-target="#navmenu">
<span class="toggler-icon top-bar"></span>
<span class="toggler-icon mid-bar"></span>
<span class="toggler-icon bot-bar"></span>
</button>
<div class="collapse navbar-collapse" id="navmenu">
<ul class="navbar-nav nav-pills ms-auto">
<li class="nav-item">
<a href="#about" class="nav-link anchor">About Us</a>
</li>
<li class="nav-item">
<a href="#services" class="nav-link anchor">Services</a>
</li>
<li class="nav-item">
<a href="#art" class="nav-link anchor">Artwork</a>
</li>
<li class="nav-item">
<a href="#contact" class="nav-link anchor">Contact Us</a>
</li>
</ul>
</div>
</div>
</nav>
I have been searching for solutions using bootstrap 4, but haven't found a suitable one yet.