I'm currently working with Bootstrap tabs on my website. I have three tabs, and when a user clicks on one, the active and focus classes are added to indicate which tab is selected.
However, I've encountered an issue where clicking anywhere else on the website removes the active and focus classes. Despite trying various solutions found online, I haven't been able to resolve this issue.
I will provide images and code for reference below:
.nav>li>a:focus,
.nav>li>a:hover {
color: #4272d7 !important;
<ul class="nav nav-tabs">
<li class="" aria-expanded="false"><a class="bg-account active" data-toggle="tab" href="#menu1" aria-expanded="true">My Account</a></li>
<li><a class="bg-invite" data-toggle="tab" href="#menu2" aria-expanded="false">Referral</a></li>
<li><a class="bg-lottery" data-toggle="tab" href="#menu3" aria-expanded="false">Lottery Results</a></li>
</ul>
Image 1: Active and focus states (desired behavior)
https://i.sstatic.net/VzdMW.png
Image 2: Issue occurs when clicking elsewhere on the website, causing active and focus classes to be removed.
https://i.sstatic.net/qGGtQ.png
If anyone can offer assistance, I would greatly appreciate it. I've been struggling with this problem for the past two days without any success.