Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
I am having some problems with my header as on my setting I selected the fixed header but it is not working.
How can I solve it?
www.sosober.it
password: mohwhi
Thank you!!
To fixed this kind of issues
Add Custom CSS Code
You can add custom CSS code to your theme's stylesheet to make the header sticky. Here's an example:
- Go to Online Store > Themes > Actions > Edit code
- Open the `theme.scss.liquid` file in the Assets folder
- Add the following code at the bottom:
#shopify-section-header {
position: fixed;
z-index: 1000;
left: 0;
right: 0;
box-shadow: 0px 2px 4px 0px rgba(0, 0, 0, 0.1);
background-color: {{ settings.color_body_bg }};
}
#PageContainer {
padding-top: 80px;
}
- Save the changes
Or try to Modify JavaScript Code
You may also need to modify the JavaScript code to adjust the header's position dynamically:
- Open the `theme.js` file in the Assets folder
- Add the following code at the bottom:
function headerSize() {
var $headerHeight = $('div#shopify-section-header').outerHeight();
$('#PageContainer').css('padding-top', $headerHeight);
}
$(window).on("load", headerSize);
$(window).on("resize", $.debounce(500, headerSize));
- Save the changes
Using of Alternative CSS also
- Add the following code to your stylesheet:
header#SiteHeader {
position: fixed !important;
width: 100% !important;
}
- Save the changes
If none of these
solutions work, feel free to let me know
Hi @sosober
Can I know what problem you are getting?
- Helpful? Like & Accept solution!
- Ryviu - Product Reviews & QA app: Collect customer reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Dhgate and CSV.
- 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.
- Enjoy 1 month of Shopify for $1. Sign up now.