On the homepage - The header is having transparent background with a white colour logo at the moment. I want it change to a white background when user scrolling down the page, meanwhile the logo color should also be changed to purple.
The other pages, the header background remains white with a purple color logo.
I think this should be adjusted on both desktop and mobile
Use JavaScript or jQuery to toggle the scrolled class on the header when the user scrolls down the page.
document.addEventListener("DOMContentLoaded", function () {
const header = document.getElementById("main-header");
if (header && document.body.classList.contains("homepage")) {
window.addEventListener("scroll", function () {
if (window.scrollY > 50) {
header.classList.add("scrolled");
} else {
header.classList.remove("scrolled");
}
});
}
});
Ensure Mobile Responsiveness:
Test the behavior on both desktop and mobile devices to confirm it works correctly.
Use media queries in CSS if adjustments are required for mobile.
Save your changes and test them on your site
Let me know if you need help with implementation or further clarification!
If I was able to help you, please don’t forget to Like and mark it as the Solution!
If you’re looking for expert help with customization or coding, I’d be delighted to support you. Please don’t hesitate to reach out via the email in my signature below—I’m here to help bring your vision to life!
I think there’re some parts of my codes are not working? because the site didn’t have the sticky header on the top no matter I set it as “always” or “always, reduce the logo size”.