I'm learning to use bootstrap 5, so bear with me if this question seems a bit basic!
I'm toying around with tabs to generate tabbable panes of local content. I've used the code provided in the documentation here : https://getbootstrap.com/docs/5.0/components/navs-tabs/#javascript-behavior
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<button class="nav-link active" id="home-tab" data-bs-toggle="tab" data-bs-target="#home" type="button" role="tab" aria-controls="home" aria-selected="true">Home</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="profile-tab" data-bs-toggle="tab" data-bs-target="#profile" type="button" role="tab" aria-controls="profile" aria-selected="false">Profile</button>
</li>
<li class="nav-item" role="presentation">
<button class="nav-link" id="contact-tab" data-bs-toggle="tab" data-bs-target="#contact" type="button" role="tab" aria-controls="contact" aria-selected="false">Contact</button>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">...</div>
<div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">...</div>
<div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">...</div>
</div>
And it works perfectly. It responds well also to justify-content, so the tabs are easy to center or distribute. Exactly what I am looking for.
But, I can't make them split with auto margins (mr-auto and ml-auto) so that, for example, the first two tabs will be aligned on the left and the last one on the right. When I include them in the ul tag, it is just ignored (while the justify-content work just fine)
I'm looking to do something like in the flex documentation : https://getbootstrap.com/docs/4.0/utilities/flex/#auto-margins or in Wikipedia where the article and talk tabs are on the left, and the read, edit and history are on the right. How could I do that?
Change your last li
like :
<li class="nav-item ms-auto" role="presentation">
<button class="nav-link" id="contact-tab" data-bs-toggle="tab" data-bs-target="#contact" type="button" role="tab" aria-controls="contact" aria-selected="false">Contact</button>
</li>
In Bootstrap 5,
For More Info : here