I cannot get my custom header group to be sticky

Topic summary

A user created a custom horizontal swipe navigation menu positioned below the main header using Liquid and CSS. The menu is set to position: sticky but doesn’t reappear when scrolling up mid-page—it only shows when scrolling all the way to the top, unlike the main header which reappears during upward scrolling.

Initial Code:

  • CSS uses position: sticky, top: 0, and z-index: 1
  • Liquid template includes a hide_on_scroll option with transform animations
  • Menu displays correctly at the top but fails to stick properly during scroll

Solution Provided:
A helper suggested CSS modifications to fix the sticky behavior:

  • Set the announcement bar to position: fixed with z-index: 99
  • Adjust header positioning with top: 37px
  • Synchronize hide/show animations using transform values (translateY(-100%) and translateY(-170%))

Current Status:
The user initially reported the horizontal header disappeared entirely after applying the fix. The helper provided a video demonstration showing the code working as expected. Awaiting confirmation whether the solution resolves the synchronization issue between the main header and custom navigation menu.

Summarized with AI on November 2. AI used: claude-sonnet-4-5-20250929.

I recently coded a Custom Horizontal swipe navigation menu as a header group below the header. However if i scroll down a product page and then back up slightly the header reappears but not the horizontal navigation menu. It only appears when i scroll all the way to the top. I’m unsure if this is a custom CSS issue or a liquid issue, ive tried everything in both but cant get it to work.

Below is My custom CSS.
.mobile-category-nav {
position: sticky;
top: 0;
z-index: 1;
background: #efefef;
transition: transform 0.3s ease-in-out; /* Ensures smooth hiding/showing /
}
.nav-wrapper {
background: #efefef;
}
.nav-item a {
font-family: “Futura Semi Bold”, Arial, sans-serif;
font-weight: 550;
}
.nav-item {
padding-top: 1px;
padding-bottom: 1px;
}
.mobile-category-nav.hide {
transform: translateY(
-100%
); /
Moves the nav bar up out of the visible area */
}

Here is my custom liquid.

{% if section.settings.show_section %}
{% if section.settings.menu != blank %}

{% endif %} {% endif %}

{% stylesheet %}
/* Wrapper styles */
.mobile-category-nav {
position: sticky;
top: 0;
left: 0;
right: 0;
width: 100%;
z-index: 999;
background: #efefef;
}

.mobile-category-nav[data-hide-scroll=“true”] {
transition: transform 0.3s ease;
}

.mobile-category-nav.hide {
transform: translateY(-100%);
}

.mobile-category-nav .nav-wrapper {
overflow-x: auto;
white-space: nowrap;
-webkit-overflow-scrolling: touch; /* Smooth scrolling on touch devices /
overflow-y: hidden; /
Hide vertical scrollbar */
}

/* Hide scrollbar across all browsers */
.mobile-category-nav .nav-wrapper::-webkit-scrollbar {
display: none;
}

/* Navigation item styles */
.mobile-category-nav .nav-item {
display: inline-block;
padding: 10px 15px;
}

/* Link styles */
.mobile-category-nav a {
display: block;
text-decoration: none;
color: #333;
font-size: 16px;
}

/* Additional container styles */
.mobile-category-nav {
text-align: center;
}

/* List and list item styles */
.mobile-category-nav ul {
list-style-type: none;
padding: 0;
margin: 0;
}

.mobile-category-nav li {
margin-right: 20px; /* Space between items */
}
{% endstylesheet %}

{% javascript %}
document.addEventListener(‘DOMContentLoaded’, function() {
const nav = document.querySelector(‘.mobile-category-nav’);
if (!nav || nav.getAttribute(‘data-hide-scroll’) !== ‘true’) return;

let lastScroll = window.pageYOffset || document.documentElement.scrollTop;
let scrollThreshold = 20; // Smaller threshold for more sensitivity

window.addEventListener(‘scroll’, () => {
const currentScroll = window.pageYOffset || document.documentElement.scrollTop;

// Always show the bar if scrolling up slightly or reaching the top of the page
if (currentScroll <= 0 || currentScroll < lastScroll - scrollThreshold) {
nav.classList.remove(‘hide’);
} else if (currentScroll > lastScroll + scrollThreshold) {
nav.classList.add(‘hide’);
}

lastScroll = currentScroll;

// Debug logs to understand behavior
console.log(Current Scroll: ${currentScroll}, Last Scroll: ${lastScroll}, Nav Class: ${nav.classList.contains('hide') ? 'Hidden' : 'Visible'});
});
});
{% endjavascript %}

{% schema %}
{
“name”: “Mobile Category Nav”,
“settings”: [
{
“type”: “checkbox”,
“id”: “show_section”,
“label”: “Show Mobile Category Nav”,
“default”: true
},
{
“type”: “checkbox”,
“id”: “hide_on_scroll”,
“label”: “Hide on scroll”,
“default”: false
},
{
“type”: “link_list”,
“id”: “menu”,
“label”: “Menu”,
“default”: “main-menu”,
“info”: “Select the menu to display”
},
{
“type”: “color”,
“id”: “text_color”,
“label”: “Text Color”,
“default”: “#333333
},
{
“type”: “color”,
“id”: “border_color”,
“label”: “Border Color”,
“default”: “#000000
},
{
“type”: “range”,
“id”: “spacing”,
“label”: “Spacing Between Links”,
“default”: 20,
“min”: 0,
“max”: 100,
“step”: 1,
“unit”: “px”
},
{
“type”: “select”,
“id”: “font_family”,
“label”: “Font Style”,
“options”: [
{
“value”: “heading”,
“label”: “Heading Font”
},
{
“value”: “subheading”,
“label”: “Subheading Font”
},
{
“value”: “body”,
“label”: “Body Font”
}
],
“default”: “heading”
}
],
“presets”: [
{
“name”: “Mobile Category Nav”,
“category”: “Custom”
}
]
}
{% endschema %}

Hi @jocons

Please share store URL so I can take a closer look

Best,

Daisy

Hi Daisy,
My store is locked, and I’d prefer to not give out the password to the public. Ive attached a few photos below of the issue. The first photo Ive circled the horizontal slider menu and the second photo shows that when i scroll down and then up again the slider menu does not reappear but the header does. The horizontal menu only appears when I reach the very top. Please let me know if there is a way to privately message you the url and password. Thank you so much

Hi @jocons

Please inbox me the URL and password

Thanks daisy,
I’ve just messaged you.

Hi @jocons

To complete your requests, please follow these steps:

  1. Go to Shopify Admin > Online Store > Theme > Customize > Theme Settings > Custom CSS https://prnt.sc/i8ljAMlHJUKl
  2. Paste the code provided into the Custom CSS section.
aside.shopify-section-group-header-group.shopify-section--announcement-bar {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 99;
}
header.shopify-section-group-header-group.shopify-section--header {
    top: 37px !important;
}
body:has(x-header.header.is-hidden) aside.shopify-section-group-header-group.shopify-section--announcement-bar {
    transform: translateY(-100%);
}
x-header.header.is-hidden {
    transform: translateY(-170%);
}

Here is the result:

I hope this helps

Best,

Daisy

Hi Daisy,

It seems the adjustments made caused the entire horizontal header bar to disappear. What I’m aiming for is to have the header bar behave exactly like the main header: it should be visible at the top, disappear when scrolling down 9Hide on scroll which it currently does), and reappear when scrolling up, even if someone is in the middle of the webpage. This should happen synchronously with the main header as it drops down. Can we adjust it to function this way?

Thanks for your help!

HI @jocons

I checked my code and and saw it works as you expected. Could you please watch this video of before and after adding code to see if it what you are looking for ?

https://www.loom.com/share/e3b7f2f046d6432aa7b633c70133a5d8

Best,

Daisy