Answers for "sticky header on scroll"

3

sticky header css

nav {
    position: sticky; top: 0;
}
Posted by: Guest on September-19-2021
-1

how to scroll fixed position

.fixed-content {
    top: 0;
    bottom:0;
    position:fixed;
    overflow-y:scroll;
    overflow-x:hidden;
}
Posted by: Guest on June-20-2020
0

sticky header on scroll

*****************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');
});
Posted by: Guest on September-07-2021

Browse Popular Code Answers by Language