onsrcoll sticky header

PHOTO EMBED

Tue May 10 2022 10:12:54 GMT+0000 (UTC)

Saved by @ali_naqvi #js #html #css

HTML

<div class="sticky"></div>


CSS

.fixed {
    position: fixed;
    top:0; left:0;
    width: 100%;
}


jQuery

$(window).scroll(function(){
  var sticky = $('.sticky'),
      scroll = $(window).scrollTop();

  if (scroll >= 100) sticky.addClass('fixed');
  else sticky.removeClass('fixed');
});
content_copyCOPY