javascript - Div only fixed between two divs -


i want use following code (demo here). there way not have fixed div scroll between points set in pixels top, between 2 divs above , below fixed div?

$(window).scroll(function(){     $("#thefixed").css("top",math.max(0,250-$(this).scrolltop())); }); 

not sure understand question long modify

math.max(0,250-$(this).scrolltop())  

there should no specification. (20,250...) 20 px top.

and if want specify div can use $('thediv').offset()

like :

var offset = $("#thefixed").offset() $(window).scroll(function(){     $("#thefixed").css("top",math.max(offset.top,250-$(this).scrolltop())); }); 

live exemple there


Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -