To hide your header while scrolling down and show it when scrolling up, add the following custom JavaScript and CSS code to your theme:
Steps:
1-Access Theme Editor:
Go to Shopify Admin > Online Store > Themes > Click Actions > Edit Code.
2-Add Javascript:
Open the theme.liquid file or a layout/theme.liquid file.
Just before the closing tag, add the following script:
3-Add CSS:
Open the theme.css or styles.css file.
Add the following CSS to enable smooth transitions:
header {
transition: transform 0.3s ease-in-out;
position: fixed;
top: 0;
width: 100%;
z-index: 9999;
}
4-Save and Test:
Save the changes and refresh your website to test the functionality.
If your header has a specific class or ID, replace “header” in the script with your actual selector (e.g., .site-header or header). Adjust the script and styles to match your website structure.