Jump to content

Stock category navigation on mobile devices

Go to solution Solved by paul2009,

Recommended Posts

Posted

Site URL: https://www.cboothandson.co.uk/

Hello

I'm hoping someone can help me with this issue.


I want to insert some CSS that will stack the different 'category navigation' links at the top of a product page on top of one another when viewing a product page on mobile devices.


At the moment customers have to scroll along the 'category navigation bar' to find the category they are looking for. There is no indicator for the customer either, so unless they know this is how this site works they will miss a number of the categories.
I have attached a screenshot below of how I would like them to appear on mobile devices - or something similar.


Thank you in advance.

Capture.JPG

  • Solution
Posted (edited)

Try something like this in Design > Custom CSS:

@media only screen and (max-width: 640px) {
  .products.collection-content-wrapper .nested-category-children {
    flex-wrap: wrap;
    overflow-x: hidden;
    justify-content: center;
  }
  .products.collection-content-wrapper .nested-category-title {
    text-align: center;
  }
}

1946425749_Screenshot2021-01-20at15_09_38.thumb.png.f516b5d199118c6315bd00037ae1a14e.png

Did this help? Please give feedback by clicking an icon below  ⬇️

Edited by paul2009

Me: I'm Paul, a SQSP user for >18 yrs & Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥.
Work: Founder of SF.DIGITAL. We provide high quality original extensions to supercharge your Squarespace website. 
Content: Views and opinions are my own. Links in my posts may refer to my own SF.DIGITAL products or may be affiliate links.
Forum advice is completely free. You can thank me by selecting a feedback emoji. Buying a coffee is generous but optional.

Posted
24 minutes ago, paul2009 said:

Try something like this in Design > Custom CSS:


@media only screen and (max-width: 640px) {
  .products.collection-content-wrapper .nested-category-children {
    flex-wrap: wrap;
    overflow-x: hidden;
    justify-content: center;
  }
  .products.collection-content-wrapper .nested-category-title {
    text-align: center;
  }
}

1946425749_Screenshot2021-01-20at15_09_38.thumb.png.f516b5d199118c6315bd00037ae1a14e.png

Hi @paul2009

Thank you for this, it worked perfect! Top man 😄

  • 2 months later...
Posted
On 1/20/2021 at 3:10 PM, paul2009 said:

Try something like this in Design > Custom CSS:


@media only screen and (max-width: 640px) {
  .products.collection-content-wrapper .nested-category-children {
    flex-wrap: wrap;
    overflow-x: hidden;
    justify-content: center;
  }
  .products.collection-content-wrapper .nested-category-title {
    text-align: center;
  }
}

1946425749_Screenshot2021-01-20at15_09_38.thumb.png.f516b5d199118c6315bd00037ae1a14e.png

Hi @paul2009 this worked really great however when I click on one of the categories via mobile then they all disappear again in the sub category.

Is there any way to change this so category titles are visible at all times?

website is https://hamtheillustrator.com

Posted

@HAM Try adding this to Design > Custom CSS (Dont remove Paul code)

@media screen and (max-width:767px) {
.nested-category-tree-wrapper {
    display: flex !important;
    float: none !important;
    min-width: unset !important;
    max-width: 100% !important;
}
}

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Posted
2 minutes ago, tuanphan said:

@HAM Try adding this to Design > Custom CSS (Dont remove Paul code)


@media screen and (max-width:767px) {
.nested-category-tree-wrapper {
    display: flex !important;
    float: none !important;
    min-width: unset !important;
    max-width: 100% !important;
}
}

 

Hey thanks @tuanphan this sorta worked - only issue is I now have two duplicated category menu's stacked on top of each other. Anyway to keep it so we only have Paul's menu's visible on every page?

  • 2 weeks later...
Posted
On 1/20/2021 at 3:10 PM, paul2009 said:

Try something like this in Design > Custom CSS:


@media only screen and (max-width: 640px) {
  .products.collection-content-wrapper .nested-category-children {
    flex-wrap: wrap;
    overflow-x: hidden;
    justify-content: center;
  }
  .products.collection-content-wrapper .nested-category-title {
    text-align: center;
  }
}

1946425749_Screenshot2021-01-20at15_09_38.thumb.png.f516b5d199118c6315bd00037ae1a14e.png

This solution worked great for me! So happy I tracked this solution down!

I also added this line of code to reduce the space before the categories:
    padding-top: 10px;

So it reads:

//mobile categories list

@media only screen and (max-width: 640px) {
  .products.collection-content-wrapper .nested-category-children {
    flex-wrap: wrap;
    overflow-x: hidden;
    justify-content: left;
    padding-top: 10px;
  }
  .products.collection-content-wrapper .nested-category-title {
    text-align: left;
  }


//mobile categories list end

You can change 'left' to 'center' to center the text on the mobile view too.

Screenshot 2021-04-14 at 16.19.16.png

Posted

@tuanphan @paul2009 same issue as HAM here. I want the category nav to appear on all the category pages but when I add @tuanphan's code, it duplicates the nav and it also appears as a sidebar style instead of all the category names in one line. (I'm talking about the mobile version specifically). Any way we can keep paul's code just as it is but on every category page?

url: https://www.eniwill.com/esp

Screen Shot 2021-04-16 at 10.12.48 AM.png

Posted
On 4/16/2021 at 10:13 PM, erkprk said:

@tuanphan @paul2009 same issue as HAM here. I want the category nav to appear on all the category pages but when I add @tuanphan's code, it duplicates the nav and it also appears as a sidebar style instead of all the category names in one line. (I'm talking about the mobile version specifically). Any way we can keep paul's code just as it is but on every category page?

url: https://www.eniwill.com/esp

Screen Shot 2021-04-16 at 10.12.48 AM.png

I see no category here

image.thumb.png.b0dc68646bb8adc4a5d1f7113845ff5e.png

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Posted
On 4/19/2021 at 4:09 AM, tuanphan said:

I see no category here

image.thumb.png.b0dc68646bb8adc4a5d1f7113845ff5e.png

The link should be /esp (not esp/salud). The categories disappear when you click on one of the categories.

  • 1 year later...
Posted (edited)
On 4/21/2021 at 12:33 PM, tuanphan said:

esp/salud when you clicking on salud link in left sidebar category

@tuanphan Would you be able to show me the code for the stacking of categories on mobile but for a video page at all please? www.igroomhub.com.au/microbites

 

Edited by anna_
  • 3 weeks later...
Posted

site: mistoa.mx

Hi @paul2009and @tuanphan

I'm having some issues with categories on mobile.

This is the way my categories display:

image.thumb.png.a727bfee7558f0deb93bd3e513841f6f.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

And this is the way I want them to display:

image.jpeg.73cc1ed23861e1a58528187ff328665f.jpeg

 

The code provided by @paul2009 is not working (probably because of some other code), so I would appreciate any help.

Thanks!

 

 

Posted (edited)
On 1/6/2023 at 10:17 PM, Begona said:

The code provided by @paul2009 is not working (probably because of some other code), so I would appreciate any help.

I can see that you have two errors elsewhere in your code injections. Some sections of code include additional brackets that are not required and are therefore causing errors. These errors prevent the other code from running. Take a look at the two sections of code that start with:

if($(window).width() >= 768) {

If you correct (or remove) these sections of code, other code should function 🙂

Did this help? Please give feedback by clicking an icon below  ⬇️

Edited by paul2009

Me: I'm Paul, a SQSP user for >18 yrs & Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥.
Work: Founder of SF.DIGITAL. We provide high quality original extensions to supercharge your Squarespace website. 
Content: Views and opinions are my own. Links in my posts may refer to my own SF.DIGITAL products or may be affiliate links.
Forum advice is completely free. You can thank me by selecting a feedback emoji. Buying a coffee is generous but optional.

Posted
1 hour ago, Begona said:

I removed the code you suggested, but the categories are still stacked. Do you have another idea of what might be interfering?

There is other CSS (above the new CSS) that is targeting the same elements (for example .nested-category-tree-wrapper) and forcing them to stack. Because you have used "!important" in these settings, they override all other settings, which is why the new CSS doesn't make any difference 🙂

As an aside, and for the benefit of anyone else reading this, adding !important is rarely a good idea. I see a number of posts in the forum that treat the !important tag like it is a secret weapon that solves all your custom CSS problems, but it really isn't! If custom CSS isn't working as expected, it's much better to find out why than to add !important. I hope this is helpful to someone in a similar situation.

Did this help? Please give feedback by clicking an icon below  ⬇️

Me: I'm Paul, a SQSP user for >18 yrs & Circle Leader since 2017. I value honesty, transparency, diversity and good design ♥.
Work: Founder of SF.DIGITAL. We provide high quality original extensions to supercharge your Squarespace website. 
Content: Views and opinions are my own. Links in my posts may refer to my own SF.DIGITAL products or may be affiliate links.
Forum advice is completely free. You can thank me by selecting a feedback emoji. Buying a coffee is generous but optional.

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.