- Install Script n Style WP plugin
- Enter wp admin panel --> tools --> script n style --> add jQuery
- Add the following script
jQuery(document).ready(function($) { $(window).scroll(function () { if ($(window).scrollTop() > 100) { $('header').addClass('shrink'); } else{ $('header').removeClass('shrink'); } }); });- here
- Add the following CSS
-
header.shrink{background-color: yellow;}- here
- now verify in the website (front) it is working
- Before (scrolling down)
- After (scrolling down)
- Before (scrolling down)
Source sticky header and menu shrink on page scroll