'adding active class in django according to anchor in url
I want to create one page site with navbar links which redirect to some part of the page. How add class "active" to a link if url is based on anchor (#)?
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li {% if request.path == "/" %} class="active"{% endif %}>
<a href="{% url "index" %}">Main pge</a>
</li>
<li {% if 'about_us' in request.path %} class="active"{% endif %}>
<a href="#about_us">About us</a>
</li>
<li><a href="#services">Services</a></li>
<li><a href="#contacts">Contacts</a></li>
</ul>
</div>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|