How to create sticky header bar for a website ?

sticky header

If you want to make your header Navbar sticky or fixed at Top on window scroll than here is the solution to follow.

 

So here is the jquery Scipt

jQuery(window).scroll(function() {
   var scroll = jQuery(window).scrollTop();

   if (scroll >= 200) { 
    jQuery(".nstHeader").addClass("sticky");
    } 
   else {
    jQuery(".nstHeader").removeClass("sticky");
    }

 }); 

In this script , class will added after scroll the window to 200px. You can change the number as per your condition.

 

If this help you then.. Can you buy a Cup of Coffee for me by nst webcreation paypal--OR-- nst webcreation blog coffee cup

Published by

NST

Myself Narender Singh Thakur ( NST ) and i share my Experience/Knowledge and Tricks for folks and beginners to solve their issues while making websites through this Planet.

Related Articles

2 thoughts on “How to create sticky header bar for a website ?”

Leave a Reply

Your email address will not be published. Required fields are marked *

Click to Chat