Jump to content

Need with with changing the color active nav links

Recommended Posts

Posted

Its a single page website. Here I wish to change the color of the active section on the navigation. I have added the following code but this only seems to work on force state over the link.

.header-nav-item a:active {
  1. color: #fc9e4f !important;
}
Tired this one as well
body:not(.header--menu-open) .header-nav-wrapper 
a:active {
  1. color: #fc9e4f !important;
}

Let me know  if anyone knows other ways to make this happen. Thanks team 

  • Replies 3
  • Views 595
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted
57 minutes ago, bhavanaidnani said:

Its a single page website. Here I wish to change the color of the active section on the navigation. I have added the following code but this only seems to work on force state over the link.

.header-nav-item a:active {
  1. color: #fc9e4f !important;
}
Tired this one as well
body:not(.header--menu-open) .header-nav-wrapper 
a:active {
  1. color: #fc9e4f !important;
}

Let me know  if anyone knows other ways to make this happen. Thanks team 

Can you share your site with the protected password so we can take a look?

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Pinch/Zoom images, videos - PDFs Lightbox - ...) </>  🗓️ Delivery Date Picker (Date picker form field)
Gallery block 7.1 workaround </> 🤖 Ask me anything

Posted

@bhavanaidnani Add to Settings > Advanced > code Injection > Footer

<script>
var btnContainer = document.getElementById("header");
var btns = btnContainer.getElementsByTagName("a");
for (var i = 0; i < btns.length; i++) {
  btns[i].addEventListener("click", function() {
    var current = document.getElementsByClassName("active");
    if (current.length > 0) {
      current[0].className = current[0].className.replace(" active", "");
    }
    this.className += " active";
  });
}
</script>
<style>
  .header-nav-item a.active {
   color: red !important;
}
</style>

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.