document.addEventListener('scroll',()=>{ if(window.scrollY > 1400){ document.querySelector(".sticky-atc-wrapper").style.display = "block"; } else { document.querySelector(".sticky-atc-wrapper").style.display = "none"; } }) //or this code: document.addEventListener('scroll',()=>{ function sticky_relocate_2() { var window_top = $(window).scrollTop(); var div_top = $('.comp-col--full').offset().top - 100; var div_bottom = $('.comp-row--last').offset().top - 120; if (window_top > div_top) { $('.comp-row-head--full').addClass('make_it_sticky') } //if window top reaches the limit removed class if(window_top < div_top){ $('.comp-row-head--full').removeClass('make_it_sticky'); } if (window_top > div_bottom ) { $('.comp-row-head--full').removeClass('make_it_sticky'); } } $(window).scroll(sticky_relocate_2); })
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter