To my understanding, approaching this issue would involve the following steps:
Firstly, apply the d-none d-lg-block
classes to the middle logo img
tag to ensure it only displays on desktop.
Next, include a duplicate img
as the last item in your .container-fluid
and add d-block d-lg-none
classes to make it visible on mobile but hidden on desktop.
Then, add the flex-nowrap
class to your nav
tag to ensure the logo appears inline with the toggle button.
Lastly, add the align-self-start
class to the duplicate/mobile img
to keep it inline with the toggle button when the nav is open.
This configuration should resemble the following structure:
<nav class="navbar navbar-expand-lg navbar-dark flex-nowrap">
<div class="container-fluid">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-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 justify-content-center">
<a class="nav-link" href="index.html">Home</a>
<a class="nav-link" href="#">About</a>
<img class="d-none d-lg-block" src="https://mk0leanfrontierqpi7o.kinstacdn.com/wp-content/uploads/2018/12/logo-placeholder-png.png" alt="" width="100" height="45">
<a class="nav-link" href="#">Portfolio</a>
<a class="nav-link" href="#">Contact</a>
</div>
</div>
</div>
<img class="d-block d-lg-none align-self-start" src="https://mk0leanfrontierqpi7o.kinstacdn.com/wp-content/uploads/2018/12/logo-placeholder-png.png" alt="" width="100" height="45">
</nav>
Example on Codepen
Does this align with your requirements?
[UPDATE]
Noticing your usage of Bootstrap 5, I have introduced a .text-end
container wrapping the button.nav-togger
and .navbar-collapse
, along with additional utility classes for styling purposes.
<nav class="navbar navbar-expand-lg navbar-dark flex-nowrap flex-row-reverse">
<div class="container-fluid navbar justify-content-end justify-content-lg-center">
<div class="text-end">
<button class="navbar-toggler mb-3" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<div class="navbar-nav container-fluid justify-content-center p-0">
<a class="nav-link" href="#">Home</a>
<a class="nav-link" href="#">About</a>
<img class="d-none d-lg-block" src="https://mk0leanfrontierqpi7o.kinstacdn.com/wp-content/uploads/2018/12/logo-placeholder-png.png" alt="" width="100" height="45">
<a class="nav-link" href="#">Portfolio</a>
<a class="nav-link" href="#">Contact</a>
</div>
</div>
</div>
</div>
<img class="d-block d-lg-none align-self-start" src="https://mk0leanfrontierqpi7o.kinstacdn.com/wp-content/uploads/2018/12/logo-placeholder-png.png" alt="" width="100" height="45">
</nav>
Using Bootstrap 5: Example on Codepen