Change background colour on scroll
-
Hi,
I’ve been searching through this forum and the provided answers haven’t been successful on my site.
I am needing a transparent header and then on page scroll, the background of the header needs to turn to white.
I’ve tried using the following JS in both the header and footer with no luck:
<script>
$(window).scroll(function() {
howMuchScrolled = $(window).scrollTop();
console.log(howMuchScrolled);
if (howMuchScrolled > 100) {
$(‘.site-header’).css(‘background-color’,’#FFFFFF’);
} else {
$(‘.site-header’).css(‘background-color’,’transparent’);
}
});
</script>I’ve also tried the following CSS:
.sticky-element-original:not(.sticky-element-active) {
background: #fff;
}AND
.sticky-element-original:not(.sticky-element-active) .site-header {
background: fff;
}Any help would be greatly appreciated!
P.S. I’m using Firefox
The page I need help with: [log in to see the link]
The topic ‘Change background colour on scroll’ is closed to new replies.