here i am again, i recently solved a problem where I could not get the navbar brand to go into the middle of my nav bar, however, that was fixed, but now I want to add a button right before the right navigation toggle. I have tried multiple ways, like text-align, and a few other methods that bootstrap has like d-flex
. however I cannot seem to override the justify-content-between
so i can get my sign up button to appear right before the right navigation toggle. I have left a photo below for better reference. I have also included the code for my navigation bar below the photo link. thanks in advance!
<header>
<nav class="navbar navbar-dark bg-dark" aria-label="Dark offcanvas navbar">
<div class="container-fluid d-flex justify-content-between">
<button class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#leftMainNav" aria-controls="leftMainNav" aria-label="Toggle left navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="index.php">
<img src="assets/images/logo-l.png" class="img-fluid" alt="CBS Logo">
CherryBerry <span class="text-red"> Studios </span>
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="offcanvas" data-bs-target="#rightMainNav" aria-controls="rightMainNav" aria-label="Toggle right navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="offcanvas offcanvas-end text-bg-dark" data-bs-scroll="true" tabindex="-1" id="rightMainNav" aria-labelledby="rightMainNav">
<div class="offcanvas-header">
<h5 class="offcanvas-title" id="offcanvasNavbarDarkLabel">Offcanvas</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<ul class="navbar-nav justify-content-end flex-grow-1 pe-3">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li>
<hr class="dropdown-divider">
</li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="offcanvas offcanvas-start text-bg-dark" data-bs-scroll="true" tabindex="-1" id="leftMainNav" aria-labelledby="leftMainNav">
<div class="offcanvas-header">
<h5 class="offcanvas-title" id="offcanvasNavbarDarkLabel">Offcanvas</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<ul class="navbar-nav justify-content-end flex-grow-1 pe-3">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Dropdown
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li>
<hr class="dropdown-divider">
</li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</nav>
</header>
2
Answers
you need to replace some code…
What I was trying to say in comments, was that since you already have a flex container and your toggler button as a flex item, instead of messing up the justify-content, you may just wrap that element inside a new div container and include inside it the element that should be next to the already existing one.
This is in detail the modification:
And this is the whole demo: