Seperator line on header only showing while scrolling

Topic summary

A user wants to display a separator line under their Shopify store header only when scrolling, not when the page is at the top.

Solutions Provided:

Multiple CSS-based solutions were offered:

  • Adding CSS to target the sticky header with a border
  • Using .scrolled-past-header class to conditionally show the border
  • Modifying base.css with specific color scheme classes

Resolution:

The issue was initially unresolved when CSS was added to the Custom CSS section in Theme Settings. The working solution required adding code to the theme.liquid file after the <head> tag, rather than just the Custom CSS area. The user confirmed this approach successfully implemented the scrolling-triggered separator line.

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

Hello. I only want to show the separator line under the header when scrolling. Does anyone know how to do this?

Hi @silenceclothing

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.
sticky-header.header-wrapper {
    border-bottom: 2px solid white !important;
}

Here is the result:

I hope this helps

Best,

Daisy

Hi @silenceclothing

You can add this code to Custom CSS in Online Store > Themes > Customize > Theme settings to do that

html .header-wrapper--border-bottom { border-bottom: unset; }
html .scrolled-past-header .header-wrapper--border-bottom { 
    border-bottom: .1rem solid rgba(var(--color-foreground), .08);
}

Hello @silenceclothing

Go to online store ----> themes ----> actions ----> edit code ---->base.css
add this code at the end of the file and save.

.header-wrapper.color-scheme-95fafa66-77d0-4a87-811c-eeb7bed11590.gradient.header-wrapper--border-bottom {
border-bottom: 1px solid white;
}

result

If this was helpful, hit the like button and accept the solution.
Thanks

Where do i put this code ?

Go to your store admin > Sales Channels > Online Store > Themes > Customize > Theme settings > Custom CSS

it did not work.

i only want it to show when scrolling

So please add code to theme.liquid file, after and check again


thanks. It works now!