I want to apply opacity
to the footer of my site, the footer is fixed in bottom
and behind the rest of the site type parallax effect. But I can not seem to get the opacity to stay gradually, as soon as I scroll down the scroll bar, the opacity
that was at zero becomes 1 as soon as the scroll bar reaches my footer.
This is the footer div:
<div id="rodape" class="rodape"></div>
This is css:
#rodape {
position: fixed;
bottom: 0;
z-index: -1;
}
.rodape {
width: 100%;
height: auto;
background-color: #00e676;
}
Within div
I'll put other elements like address, Google map, etc. As div
is behind the rest of the site and fixed in bottom
, to start appearing I want the opacity to be 0 and with the scroll it will increase to 1 when the scroll is finished, because it will be the end of the site. p>
I'm using the information from this codepen and this js:
var scroll = $('#rodape');
var range = 200;
$(window).on('scroll', function () {
var scrollTop = $(this).scrollTop(),
height = heade.outerHeight(),
offset = height / 2,
calc = 1 - (scrollTop - offset + range) / range;
scroll.css({ 'opacity': calc });
if (calc > '1') {
scroll.css({ 'opacity': 1 });
} else if ( calc < '0' ) {
scroll.css({ 'opacity': 0 });
}
});
Have you noticed that I do not handle a lot of javascript, right? But I want to leave this effect, does anyone know where I'm going? Is there any way to make this work, or some other solution?