3 replies [Last post]
Atraa
Atraa's picture
Offline
newbie
Last seen: 6 years 1 week ago
Timezone: GMT+2
Joined: 2014-09-15
Posts: 2
Points: 3

Hi! I am struggling with some very basic CSS that is for a Squarespace website that I am making. The template for the site automatically adds a navigation menu item for each sub page on one of those scrolling index pages. I do not want it to show a menu item for these sub pages, so after dealing with their support team, I found this code on a Squarespace forum to remove (in this case) the second menu item.

#mainNavigation > div:nth-child(2) > a {
display: none;
}

My question is quite general, I think. (And I have read the read me first page on this forum. I donĀ“t even know enough about programming to completely comply with the requirements there I am afraid.) Back to that question: how can I re-write this CSS to apply to not only the 2nd child, but also the 3rd, 4th, 5th and so on? I played around with it, and looked up the rules, without success. I am out of my depth.

I will be so grateful if anyone can help with this.

Cheers!

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 1 week 4 days ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5343
Points: 2964

Hi Atraa, Can you link to the

Hi Atraa,
Can you link to the site or past the source html so we can understand the structure.

Atraa
Atraa's picture
Offline
newbie
Last seen: 6 years 1 week ago
Timezone: GMT+2
Joined: 2014-09-15
Posts: 2
Points: 3

Hi Tony. Thanks for your

Hi Tony. Thanks for your response. I actually got feedback from the Squarespace Answers community at the same time yesterday. The answer was:

#mainNavigation > div:nth-child(2) > a,
#mainNavigation > div:nth-child(3) > a {
display: none;
}

Copy and past the div:nth-child(2) > a bit as many times are you need it, and replace the number for the menu item you want to remove from the navigation. (There is my very technical explanation!) It worked, so I am very happy!

Thanks again, and cheers from sunny Norway,
Heather

Tony
Tony's picture
Offline
Moderator
Brisbane
Last seen: 1 week 4 days ago
Brisbane
Timezone: GMT+10
Joined: 2003-03-12
Posts: 5343
Points: 2964

Hi Atraa,Thanks for sharing

Hi Atraa,
Thanks for sharing the answer.
Another cleaner way might be:

#mainNavigation > div:nth-child(1n+2) > a{
  display:none;
}

That will target every item starting at the second.