Hi everyone,
I have a transparent header that turns white on scroll. I added this CSS in base:
.header {
border-bottom: 1px solid black;
}
However, I only want the 1px line border to appear after scrolling, and not on page load or when the header returns to transparent at the top.
I think I need JS to add a class like .scrolled-past-header when the header becomes sticky.
Can someone help me with the correct JS and where to place it in the Atelier theme?
Welcome to Shopify Community! Can you share your Store URL so I can have a look on it? Also, if you have password enabled then please share the password as well. Your cooperation would be greatly appreciated.
Hi, @runwayfashion
In my opinion, the header-component has data-sticky-state attribute and you can apply css when the value of that attribute is set to “idle”
So you can add CSS like this
Atelier is a type of theme whose class updates depending on what your header setting is so without sharing your store URL or preview URL then it’s just guess work nothing else.
Without having a look at your store, I’m not sure if this would work for you or not but you can try to add this code in the “Custom CSS” option of your header in theme editor.
.header[transparent][transparent=not-sticky][data-sticky-state=active] {
border-bottom: solid 2px black !important;
}
Thank you for your reply. I’m glad to hear that the solution worked well for you. If you require any more help, please don’t hesitate to reach out. If you find this information useful, a Like would be greatly appreciated.