1
I’m here at my job, and I’m having a problem here on the website.
I have a lateral div that has a code js to stay fixed on the page (floating) as soon as it reaches top0 (follow the link below)
$(function(){
var jElement = $('.element');
$(window).scroll(function(){
if ( $(this).scrollTop() > 835 ){
jElement.css({
'position':'fixed',
'top':'10px',
'width':'50%',
'margin-left':'50%',
// 'height':'1500px'
});
}else{
jElement.css({
'position':'relative',
'top':'auto',
'width':'50%',
'margin-left':'auto'
});
}
});
While the photo on the left keeps rolling, the div on the right is fixed on the screen.
The problem is that, when you reach the end of the left photo, div keeps rolling down, causing her to get in front of the baseboard and ruin everything.
How do I get the floating div on the right to stop as soon as the photo on the left ends?
Help me if I won’t get fired (joke) kk
From what I understand you just want the div not to overlap the footer, stopping before him?
– Sam
yes... the div stop before it... without needing it to descend until the end
– Lukas Monteiro
Have you tried changing the position of relative for Absolute?
– LeAndrade
I would suggest putting
z-index: -1
in the.element
... so when you get to the footer, the floating div will be under the footer. Make it "stop" and then come back is very complicated.– Sam
Or a
z-index
in the footer so that it is on top.– Sam