Jump to content

Navigation dropdowns not working mobile only

Go to solution Solved by tuanphan,

Recommended Posts

My website (www.realchineseacademy.com) is in two languages which I've done manually by duplicating every page with translated text. I added code to each page so that being on the English pages will only make you see the English navigation links and vice versa for Chinese. Everything works fine for English pages on both desktop and mobile and Chinese pages on desktop. However on the Chinese pages on mobile when you click on any of the navigation links that have a drop down menu the page with the drop down does not display anything. 

I've used the exact same code for all pages, just replacing the numbers for the different language headers so not sure why it is not working only for these pages and only on mobile? Any help is appreciated!

image.thumb.png.eb2b392bf961efee5010451222bb1a13.pngimage.thumb.png.d4cf76418b2e711c7f1b2f8be06d656a.png

image.thumb.png.6b4e9e8b0e2c0782a3ccd9b159e23e27.pngimage.thumb.png.bd8165d01584725b1aeca6f3dfc0aa3d.png

 

Link to comment
  • Replies 2
  • Views 794
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

  • Solution

I wrote a quick guide to achieve this, you can see an example below

image.png.52f126c80432255c21eec41d69521c3a.png

image.thumb.png.2e2632391816f427dc694bc2937ec8a0.png

Next, you can add this code to Page Header (on all language 1 pages) to hide Items 3, 4, 5

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

Next, add this code to Page Header (on all language 2 pages) to hide Items 1, 2, 3

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

Based on the above example, you can adapt the code more precisely for your case.
If you still can't solve the problem, you can let me know, I will tweak code for your site

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

Link to comment

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.