All things Shopify and commerce
I am using bullet theme. There is only one option for header sticky. It sticks all the time. I need to make it sticky only scrolls up. When scrolling down, it needs to be hidden. How to do that?
I tried this js code, but not working
// Hide header on scroll down
var didScroll;
var lastScrollTop = 0;
var delta = 5;
var navbarHeight = $('header').outerHeight();
$(window).scroll(function(event){
didScroll = true;
});
setInterval(function() {
if (didScroll) {
hasScrolled();
didScroll = false;
}
}, 250);
function hasScrolled() {
var st = $(this).scrollTop();
// Make scroll more than delta
if(Math.abs(lastScrollTop - st) <= delta)
return;
// If scrolled down and past the navbar, add class .nav-up.
if (st > lastScrollTop && st > navbarHeight){
// Scroll Down
$('header').removeClass('site-header').addClass('nav-up');
} else {
// Scroll Up
if(st + $(window).height() < $(document).height()) {
$('header').removeClass('nav-up').addClass('site-header');
}
}
lastScrollTop = st;
}
Solved! Go to the solution
This is an accepted solution.
Hi @SF007
Please try to add this CSS code to theme.liquid file and check again
<style>
header.site-header {
position: sticky;
top: 0px;
}
</style>
Make sure you disable the option 'Enable sticky header' in Online store > Themes > Customize > Header
- Helpful? Like & Accept solution!
- Ryviu - Product Reviews & QA app: Import reviews from AliExpress, Amazon, Etsy, Walmart, Dhgate and CSV.
- Amazon Products Importer - Import Amazon Products to Dropship in Your Store!
- Lookfy Gallery: Lookbook Image - Gain customers with photo gallery, video & shoppable image
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- En...Sign up now.
Make sure your header has a fixed or sticky positioning to enable smooth hiding and revealing.
Like this:
header {
position: fixed;
width: 100%;
top: 0;
transition: transform 0.3s ease;
}
I got my header sticky here with this code, you should try it as well.
This is an accepted solution.
Hi @SF007
Please try to add this CSS code to theme.liquid file and check again
<style>
header.site-header {
position: sticky;
top: 0px;
}
</style>
Make sure you disable the option 'Enable sticky header' in Online store > Themes > Customize > Header
- Helpful? Like & Accept solution!
- Ryviu - Product Reviews & QA app: Import reviews from AliExpress, Amazon, Etsy, Walmart, Dhgate and CSV.
- Amazon Products Importer - Import Amazon Products to Dropship in Your Store!
- Lookfy Gallery: Lookbook Image - Gain customers with photo gallery, video & shoppable image
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- En...Sign up now.
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025