I've managed to create the underline effect on the navigation links when the user hovers over them.
However, the underline only stays visible until the user clicks elsewhere on the screen. How can I make it persist as long as the user is on the page?
Additionally, there is a button in the left-side navigation that acts as a link to the home page. Despite my efforts, the underline feature does not work on this button. Any suggestions on how to fix this?
.navbar-brand img {
height:33px;
width: auto;
}
.navbar {
line-height: 33px;
}
button {
background-color:rgb(255, 102, 0);;
}
.navbar-dark .navbar-nav > li > a {
border-bottom: 1px solid transparent;
}
.navbar-dark .navbar-nav > li > a:hover, .navbar-dark .navbar-nav > li > a:focus, .navbar-dark .navbar-nav > .active > a, .navbar-dark .navbar-nav > .active > a:hover, .navbar-dark .navbar-nav > .active > a:focus {
color: rgb(255, 102, 0);;
border-bottom: 1px solid rgb(255, 102, 0);
}
.navbar-dark .navbar-nav > button.home:hover, .navbar-dark .navbar-nav > button.home:focus, .navbar-dark .navbar-nav > .active > button.home, .navbar-dark .navbar-nav > .active > a:hover, .navbar-dark .navbar-nav > .active > a:focus {
color: rgb(255, 102, 0);
border-bottom: 1px solid rgb(255, 102, 0);
}
HTML
<nav class="navbar navbar-expand-md fixed-top navbar-dark bg-dark">
<a class="navbar-brand" routerLink="/" routerLinkActive="active">
<img src="https://via.placeholder.com/200x30" alt="" />
</a>
<button class="navbar-toggler home" (click)="isCollapsed = !isCollapsed" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarsExampleDefault" [collapse]="isCollapsed">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" routerLink="/services" routerLinkActive="active">Products</a>
</li>
<li class="nav-item">
<a class="nav-link" routerLink="/case-studies" routerLinkActive="active">Testimonials</a>
</li>
<li class="nav-item">
<a class="nav-link" routerLink="/about" routerLinkActive="active">About</a>
</li>
<li class="nav-item">
<a class="nav-link" routerLink="/blog" routerLinkActive="active">Blog</a>
</li>
</ul>
<div class="form-inline my-2 my-lg-0">
<a class="nav-link button" routerLink="/intouch" routerLinkActive="active"><button class="btn btn-outline-primary my-2 my-sm-0">Contact</button></a>
</div>
</div>
</nav>