I've been struggling to create a centered navbar in Bootstrap 5 with left-aligned brand logo. Despite trying various flexbox options, I can only manage to center the nav links within a flex container. However, the collapse feature functions correctly.
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top navbar-default">
<div class="container-fluid">
<a href="#" class="navbar-brand me-auto">
<img style="height: 45px" src="https://lanman2018.ieee-lanman.org/files/2016/01/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8bf8eae6fbe7eea6e7e4ece4cbb9f3a5fbe5ec">[email protected]</a>">
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar2">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse justify-content-center" id="navbar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">page link/a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="dropdown" aria-expanded="false">dropdown</a>
<ul class="dropdown-menu" aria-labelledby="dropdown">
<li>
<a class="dropdown-item" href="#">2nd Page</a>
</li>
<li>
<a class="dropdown-item" href="#"> This is a really long page nameS</a>
</li>
<li>
<a class="dropdown-item" href="#">still a long name</a>
</li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="#">about us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact Page</a>
</li>
</ul>
</div>
</div>
</nav>
When I position the logo as absolute, I achieve the desired outcome but encounter an issue where the collapsed nav button overlaps with the logo. I suspect I'm overlooking something simple since frontend isn't my forte.
Here's a jsfiddle link showcasing both solutions I've been experimenting with https://jsfiddle.net/0s24hLmf/