I was given the following code by someone on here to customize the colour gradient on my page but for some reason it makes the header/sidebar transparent on pages on the mobile version of my store. Could someone help me keep the colour gradient whilst making the header/sidebar just the normal white it is.
Hi @clementgordon ,
Could you please share your store URL so I can take a closer look?
If possible, it would also be helpful if you could provide a few screenshots from both desktop and mobile, especially showing the transparent header/sidebar. That way, it’ll be easier to check and suggest the right fix.
Dear,
Dani from Samita
Hello @clementgordon
Welcome to the Shopify Community! Please share your store URL and password (if it’s password-protected), so I can check and provide you with the exact solution.
The issue is that your current CSS applies the gradient background globally to the main#MainContent, which in some themes (especially on mobile) makes the header/sidebar area inherit transparency instead of keeping its solid background color.
You can fix this by limiting the gradient only to the main content area while keeping the header and sidebar with their default white background.
{% if template contains 'page' %}
<style>
/* Apply gradient only to the main content wrapper */
main#MainContent {
background: linear-gradient(180deg, rgba(255, 255, 255, 1), rgba(176, 247, 197, 1));
}
/* Reset header and sidebar to white */
header.site-header,
.site-header,
.header-wrapper,
.sidebar,
nav,
.drawer {
background: #ffffff !important;
}
/* If theme uses color scheme classes */
.color-scheme-1.gradient {
background: #ffffff !important;
}
</style>
{% endif %}
What this does:
Keeps the gradient on your page content only.
Forces the header/sidebar/drawer back to solid white (#ffffff).
Works for both desktop and mobile.
If you’d like me to implement this directly in your store (so you don’t have to worry about theme file edits), please feel free to reach out - my contact information is in my portfolio here: [https://rajatweb.dev/\]
You can also check my past Shopify works there. Thanks!
The reason your gradient disappeared is because your theme might not be using main#MainContent as the wrapper for the page content. Instead, some Shopify themes wrap content inside .page-width, .page-content, or .template-page.
We’ll need to target the right container while still forcing the header/sidebar to remain white.
If you want me to directly implement this fix for you, feel free to reach out - my contact info and past works are available in my [https://rajatweb.dev/\\\].