All things Shopify and commerce
Hi,
I am using the impulse theme and there is no option to change the color of an active menu link.
Need to enable this for both Header and Footer menus.
Can you guys help me do this please?
Thanks,
Hey @MKsac
Welcome to Shopify Community! Can you share your Store URL so I can have a look on it? Also, if you have password enabled then please share the password as well. Your cooperation would be greatly appreciated.
Best Regards,
Moeed
Hey @MKsac
Follow these Steps:
1) Go to Online Store
2) Edit Code
3) Find theme.liquid file
4) Add the following code in the bottom of the file above </body> tag
<script>
document.addEventListener('DOMContentLoaded', function () {
const menuLinks = document.querySelectorAll('header a, footer a');
menuLinks.forEach(link => {
if (link.href === window.location.href) {
link.classList.add('active-link');
}
});
});
</script>
<style>
header .active-link,
footer .active-link {
color: red;
font-weight: bold;
text-decoration: underline;
}
</style>
If I managed to help you then, don't forget to Like it and Mark it as Solution!
Best Regards,
Moeed
document.addEventListener("DOMContentLoaded", function() {
// Select all menu links
const menuLinks = document.querySelectorAll(".site-nav__link");
const currentPath = window.location.pathname;
// Loop through each link and check if it matches the current URL
menuLinks.forEach(link => {
if (link.href.includes(currentPath)) {
link.classList.add("active");
}
});
});
/* Active menu link styling */
.site-nav__link.active {
color: #FF5733 !important; /* Replace with your desired color */
font-weight: bold; /* Optional: Make it bold */
text-decoration: underline; /* Optional: Underline the link */
}
/* Optional: Active state for dropdown links */
.site-nav__dropdown .site-nav__link.active {
background-color: #f0f0f0; /* Highlight dropdown active link */
}
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024