Skip to content

Instantly share code, notes, and snippets.

@Nikeshsuwal
Last active March 24, 2016 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nikeshsuwal/40b06c8ed6196c6eabc8 to your computer and use it in GitHub Desktop.
Save Nikeshsuwal/40b06c8ed6196c6eabc8 to your computer and use it in GitHub Desktop.
fixed content in certain position after scrolling
$(window).scroll(function(){
header_height = $('.inner_header-bg').height(); //header height
content_height = $('.joinus-home').offset().top; //content height
window_scroll = $(window).scrollTop(); //scrolling value
header_footer_height= 554+115 //total height of header and footer
pos = content_height - header_footer_height;
filter_col = $('.item_filter').parent().width();
if ( pos > window_scroll) {
$('.item_filter').css({
'position': 'fixed',
'top': header_height,
'width': '100%',
'max-width': filter_col
})
}
else{
$('.item_filter').css({
'position': 'absolute',
'top': pos
})
}
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment