-2
Hello. I am making a site with tabs, and would like to know how to make the section (word) of the menu highlighted according to the image. I managed to put, but it only stays on the menu Beginning, I would like when I was on the page About blue dash was on the menu About and so on if you accessed the other menu items. Thank you very much.
HTML code
<div class="nav__menu" id="nav-menu">
<ul class="nav__list">
<li class="nav__item"><a href="{% url 'pages:home' %}" class="nav__link active">Início</a></li>
<li class="nav__item"><a href="{% url 'pages:sobre' %}" class="nav__link">Sobre</a></li>
<li class="nav__item"><a href="{% url 'pages:skills' %}" class="nav__link">Skills</a></li>
<li class="nav__item"><a href="{% url 'pages:projetos' %}" class="nav__link">Trabalho</a></li>
<li class="nav__item"><a href="{% url 'blog:list' %}" class="nav__link">Blog</a></li>
<li class="nav__item"><a href="{% url 'contato:contato_email' %}" class="nav__link">Contato</a></li>
</ul>
</div>
JS Code
$('.nav__link').click(function(){
//remove class active
$('.nav__link').removeClass('active');
//adiciona class active ao item clicado
$(this).addClass('active');
});
If vc will try with JS an alternative that you can test is to take the window.Location and apply the class on the option with the corresponding href
– hugocsl
I put CSS too, but it only gets stuck at the beginning, it’s not dynamic.
.active::after{
 position: absolute;
 content: "";
 width: 100%;
 height: 0.18rem;
 left: 0;
 top: 2rem;
 background-color: var(--first-color);
}
– epc