1

Trying to make a sticky banner in the right sidebar on http://lukich.co.nf/laestrella/ But can't figure out how to define it's stop point a few pixels before the red line above footer. Can someone help please. the script:

$(function(){ // document ready if (!!$('#sticky').length) { // make sure "#sticky" element exists var el = $('#sticky'); var stickyTop = $('#sticky').offset().top -100; $(window).scroll(function(){ // scroll event var windowTop = $(window).scrollTop(); if (stickyTop < windowTop){ el.css({ position: 'fixed', top: 50 }); } else { el.css('position','static'); } }); } }); 

1 Answer 1

1

I visited mentioned the site and tried to give fix by using browser console. Please debug below code surely it will work. Just you have to analyse little bit.

var el = $('#sticky'); var stickyTop = $('footer').offset().top; $(window).scroll(function(){ var windowTop = $(window).scrollTop(); var z= $(window).height(); if ($(this).scrollTop() > 50) { if(windowTop + z > stickyTop){ $('#sticky').css('display','block'); } else { $('#sticky').css('display','none'); } } 

});

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.