Jump to content

Hide header elements on mobile version.

Go to solution Solved by Ziggy,

Recommended Posts

Posted (edited)

Site URL:  https://bridge-sa.net/

Hello, on my website in order to implement a language switcher that keeps you on the same page once you switch language i added a bunch of elements to the header and then hide all the ones in Arabic on the English pages and viceversa.

Issue is on the mobile version the drop down menu still shows every single header page, how can i fix this?

Images for comparison:

https://prnt.sc/5kFl5sANCqpQ (Homepage header on desktop)

https://prnt.sc/xOQZ2affsdle (Homepage dropdown header menu on mobile version)

Edited by GiorgioDesign
Posted (edited)

Can you share your website URL?

How are you hiding the language navigation items on desktop currently?

Edited by Ziggy

Please like and upvote if my comments were helpful to you. Cheers!

Zygmunt Spray
Squarespace Website Designer
Contact me: 
https://squarefortytwo.com 
Hire me on Upwork!

📈 SEO Space (Referral link)
Ⓜ️ 
Will Myers' Plugins & Tutorials (Referral link)
 🔌 Ghost Squarespace Plugins (Referral link)
 SquareWebsites Plugins (Referral link)
 🔲SQSP Themes (Referral link) 
Spark Plugin (Referral link) 
 🖼️Pinch-to-Zoom Gallery Lightbox Plugin (Referral link) 

 Did I help? Buy me a coffee?

Posted
Just now, Ziggy said:

Can you share your website URL?

How are you hiding the language navigation items on desktop currently?

Site URL: https://bridge-sa.net/

I'm currently hiding the items using this code in the page settings advanced tab:

<style>
#header .header-nav-item:nth-child(2) {display:none}
  
#header .header-nav-item:nth-child(5) {display:none}
  
#header .header-nav-item:nth-child(7) {display:none}
  
 #header .header-nav-item:nth-child(9) {display:none}
  
 #header .header-nav-item:nth-child(10) {display:none}
  
  #header .header-nav-item:nth-child(11) {display:none}

  </style>

  • Solution
Posted

Add this alongside the other CSS, the mobile menu has different selectors to the desktop navigation:

.header-menu-nav-item:nth-child(2) {display:none;}
.header-menu-nav-item:nth-child(5) {display:none;}
.header-menu-nav-item:nth-child(7) {display:none;}
.header-menu-nav-item:nth-child(9) {display:none;}
.header-menu-nav-item:nth-child(10) {display:none;}
.header-menu-nav-item:nth-child(11) {display:none;}

Please like and upvote if my comments were helpful to you. Cheers!

Zygmunt Spray
Squarespace Website Designer
Contact me: 
https://squarefortytwo.com 
Hire me on Upwork!

📈 SEO Space (Referral link)
Ⓜ️ 
Will Myers' Plugins & Tutorials (Referral link)
 🔌 Ghost Squarespace Plugins (Referral link)
 SquareWebsites Plugins (Referral link)
 🔲SQSP Themes (Referral link) 
Spark Plugin (Referral link) 
 🖼️Pinch-to-Zoom Gallery Lightbox Plugin (Referral link) 

 Did I help? Buy me a coffee?

Posted
29 minutes ago, GiorgioDesign said:

Works like a charm, yhanks a bunch, spared me lots of headaches!

Not a problem! Could you mark my post as the solution to your question and give it a like? Thanks!

Please like and upvote if my comments were helpful to you. Cheers!

Zygmunt Spray
Squarespace Website Designer
Contact me: 
https://squarefortytwo.com 
Hire me on Upwork!

📈 SEO Space (Referral link)
Ⓜ️ 
Will Myers' Plugins & Tutorials (Referral link)
 🔌 Ghost Squarespace Plugins (Referral link)
 SquareWebsites Plugins (Referral link)
 🔲SQSP Themes (Referral link) 
Spark Plugin (Referral link) 
 🖼️Pinch-to-Zoom Gallery Lightbox Plugin (Referral link) 

 Did I help? Buy me a coffee?

  • 1 year later...
Posted

Hi, I'm having trouble with this code for the mobile version. 

I use Dropdown elements in my navigation. This works fine with this code on desktop mode.
On mobile mode it does not show me all the elements in the dropdown menu. 

Can you help me?

Thanks!

This is what I coded:
 

<style>
  #header .header-nav-item:nth-child(1){
    display:none
  }
  #header .header-nav-item:nth-child(3){
    display:none
  }
  #header .header-nav-item:nth-child(5){
    display:none
  }
  #header .header-nav-item:nth-child(7){
    display:none
  }
</style>

<style>
  @media screen and (max-width:1511px){
    #header .header-menu-nav-item:nth-child(1) {
      display:none;
    }
    #header .header-menu-nav-item:nth-child(3) {
      display:none;
    }
    #header .header-menu-nav-item:nth-child(5) {
      display:none;
    }
    #header .header-menu-nav-item:nth-child(7) {
      display:none;
    }
</style>

Posted
On 10/26/2024 at 12:03 AM, ybalis said:

Hi, I'm having trouble with this code for the mobile version. 

I use Dropdown elements in my navigation. This works fine with this code on desktop mode.
On mobile mode it does not show me all the elements in the dropdown menu. 

Can you help me?

Thanks!

This is what I coded:
 

<style>
  #header .header-nav-item:nth-child(1){
    display:none
  }
  #header .header-nav-item:nth-child(3){
    display:none
  }
  #header .header-nav-item:nth-child(5){
    display:none
  }
  #header .header-nav-item:nth-child(7){
    display:none
  }
</style>

<style>
  @media screen and (max-width:1511px){
    #header .header-menu-nav-item:nth-child(1) {
      display:none;
    }
    #header .header-menu-nav-item:nth-child(3) {
      display:none;
    }
    #header .header-menu-nav-item:nth-child(5) {
      display:none;
    }
    #header .header-menu-nav-item:nth-child(7) {
      display:none;
    }
</style>

Remove your code & use this approach

<style>
/* hide items on desktop */
nav.header-nav-list>div:nth-child(1), nav.header-nav-list>div:nth-child(3), nav.header-nav-list>div:nth-child(5), nav.header-nav-list>div:nth-child(7) {
    display: none;
}
/* hide items on mobile */
[data-folder="root"]>div:first-child>div:first-child>div:nth-child(1), [data-folder="root"]>div:first-child>div:first-child>div:nth-child(3), [data-folder="root"]>div:first-child>div:first-child>div:nth-child(5), [data-folder="root"]>div:first-child>div:first-child>div:nth-child(7) {
    display: none;
}
</style>

 

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!)

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.