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

Sticky filters on product page - Colorblock theme

Solved

Sticky filters on product page - Colorblock theme

ac-ado
Tourist
13 1 1

Hi!

Is there any way to make the filters on the products page in the Colorblock theme sticky?

Right now I have them left of the products and I'm using the "Search & Discovery" App

 

Thanks!

Accepted Solution (1)
tim
Shopify Partner
4812 598 1733

This is an accepted solution.

You do not need this Javascript stuff.

 

Simply add this code to the "product grid" sections "Custom CSS" setting instead:

@media (min-width:750px) {
  .facets-container {
    position: sticky;
    top: var(--header-height,0);
  }
}

 Avoid editing theme code as code edits will make future theme updates difficult.

If my post is helpful, hit the thumb up button -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com

View solution in original post

Replies 8 (8)

Shadab_dev
Shopify Partner
1583 83 173

Share your store url. Css can handle your requirement.

Buy me Coffee, if you feel i was helpful. Email Me here or WhatsApp me with this link for any help with shopify theme customizations or any project in web dev. If this is helpful, please Like and Accept the solution.
ac-ado
Tourist
13 1 1
tim
Shopify Partner
4812 598 1733

This is an accepted solution.

You do not need this Javascript stuff.

 

Simply add this code to the "product grid" sections "Custom CSS" setting instead:

@media (min-width:750px) {
  .facets-container {
    position: sticky;
    top: var(--header-height,0);
  }
}

 Avoid editing theme code as code edits will make future theme updates difficult.

If my post is helpful, hit the thumb up button -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com
ac-ado
Tourist
13 1 1

Perfect, thank you, Tim!

Worked like a charm 🙂

Guleria
Shopify Partner
4299 825 1189

Hello @ac-ado ,

 

Edit theme.liquid search for </body> 

once found just before to it add this code

<script>
window.addEventListener('scroll', function () {
  const headerbg = document.getElementById("main-collection-filters");
  if (window.scrollY > 40) {
    headerbg.classList.add('hasbg');
  } else {
    headerbg.classList.remove('hasbg');
  }
});
</script>
<style>
.hasbg div#FacetsWrapperDesktop {
    position: fixed;
    top: 0;
}
</style>

 

Regards
Guleria

- Elevate Your Store with Expert Shopify Services. Email: guleriathakur43@gmail.com - Need a quick fix or a tailored customization? I’ve got you covered.
- Looking to enhance your pages? Try GEMPAGES- a powerful drag & drop page builder.
- Let’s make your store stand out. Get in touch today!
- My Apps: Productify Groups – Smart product grouping made easy.
ac-ado
Tourist
13 1 1

Thanks for your reply!

It doesn't give any results for </body>, I'm afraid...

ac-ado
Tourist
13 1 1

Sorry, gave up too soon 🙂

It worked, but the first filter slides under the header on scroll..

Guleria
Shopify Partner
4299 825 1189

 

Update the code

<script>
window.addEventListener('scroll', function () {
  const headerbg = document.getElementById("main-collection-filters");
  if (window.scrollY > 40) {
    headerbg.classList.add('hasbg');
  } else {
    headerbg.classList.remove('hasbg');
  }
});
</script>
<style>
.hasbg div#FacetsWrapperDesktop {
    position: fixed;
    top: 32%; 
    z-index: 1;
    width: 15%;
}
</style>
- Elevate Your Store with Expert Shopify Services. Email: guleriathakur43@gmail.com - Need a quick fix or a tailored customization? I’ve got you covered.
- Looking to enhance your pages? Try GEMPAGES- a powerful drag & drop page builder.
- Let’s make your store stand out. Get in touch today!
- My Apps: Productify Groups – Smart product grouping made easy.