So, I've been facing a challenge with my Bootstrap 4 navigation bar. The nav-items are going right across the navbar but I want the spacing between each nav item to adjust based on the viewport size to prevent any items from falling outside of view. It's similar to what you see here:
I tried setting the padding between the nav items in ems, but that didn't work. I also attempted to justify the text, but the padding still doesn't adapt.
Below is the CSS code:
.mynav .myBrand {
color: #fff;
font-size: 36px;
}
.navbar {
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
width: 100%;
background-color: rgba(0, 0, 0, 0.6);
padding: 30px 0 30px 0;
}
/*link*/
.navbar .navbar-nav li a {
color: #fff;
font-size: 25px;
font-weight: 600;
font-family: Helvetica, Arial, Verdana, sans-serif;
text-transform: uppercase;
}
.navbar-nav .nav-link:hover {
color: #cda45e;
}
/*link hover color*/
.navbar-nav .nav-link:focus {
color: #fff;
outline: 0;
}
/*link focus color*/
/*Nav item spacing*/
.navbar-nav>li {
padding-right: 9em;
}
// More CSS Code Here...
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="14767b7b60676066756454203a223a25">[email protected]</a>/dist/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f59f848090878cb5c6dbc3dbc5">[email protected]</a>/dist/jquery.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="54dfcacfdbde">[email protected]</a>/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8ec19d83889d95bcafc2cbc1aecac2dad5">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>
<nav class="navbar navbar-expand-lg mynav " id="navbar_top">
<div class="container-fluid">
<a class="navbar-brand myBrand pl-xl-5" href="index.html">Web Title</a>
<button class="navbar-toggler custom-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<i class="fa-solid fa-bars fa-xl" style="width:40px"></i>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#top-content">Top</a>
</li>
<!-- More Links Here -->
</ul>
</div>
</nav>