0
I want to apply opacity
at the bottom of my site, the footer is fixed on bottom
and behind the rest of the site type effect Parallax. But I can not make it gradually become opaque, so scroll the opacity
that was at zero get 1 once the scrollbar arrived at my footer.
This is the div of the footer:
<div id="rodape" class="rodape"></div>
This is the css:
#rodape {
position: fixed;
bottom: 0;
z-index: -1;
}
.rodape {
width: 100%;
height: auto;
background-color: #00e676;
}
Within the div
I will put other elements like address, Google map, etc. Like the div
is behind the rest of the site and fixed on bottom
, start to appear I want the opacity to be 0 and with the scroll increases up to 1 when the scroll ends, because it will be the end of the site.
I’m using the information of this codepen and that 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 });
}
});
You realize that I don’t know much about javascript, right, but I want to leave it at that, does anyone know where I’m going wrong? Is there any way to make it work, or some other solution?
it worked but as it is at the end of the site the effect is applied almost in half of the scroll would have to begin to appear more for the end of the scroll, has to control that?
– Clayton Furlanetto
@Claytonfurlanetto, try the other solution in the edited answer
– user60252
yes it worked, but as soon as the image appears the opacity is not this 0 is already about 50% visible and as the footer is behind the rest of the site type Parallax effect can not notice much, because it already appears little transparent, I’m seeing if in the code I can make it appear more transparent.
– Clayton Furlanetto
@Claytonfurlanetto, increases the value in
transition: opacity 1.5s;
fortransition: opacity 2.5s;
or more– user60252
Blz now worked out vlw thank you so much
– Clayton Furlanetto