Home › Forums › Support › How to create a colored border around the menue items in the primary navigation
- This topic has 10 replies, 4 voices, and was last updated 3 years, 3 months ago by
Fernando.
-
AuthorPosts
-
May 7, 2022 at 4:19 am #2212297
martin
Hi there !
Tried to make around every single menue item in the primary navigation a colored (white) border.
the url is ea-tech.at , thxs !rgds martin
May 7, 2022 at 5:04 am #2212323David
StaffCustomer SupportHi there,
this CSS will add a border to the menu item:
.main-navigation li { border: 1px solid #fff; }May 7, 2022 at 5:08 am #2212326martin
Perfect! Thxs for your swift reply !
rgds
May 7, 2022 at 5:26 am #2212340David
StaffCustomer SupportYou’re welcome
January 15, 2023 at 7:55 pm #2496810Henry
Hi David / Support Team
Just asking about the above – what if I wanted to only allow the border on certain menu items (i.e. not ALL of the menu items)?
.main-navigation li { border: 1px solid #fff; }^ I think the above needs an extra class added to it that I can apply to the menu items that I would like to see a border.
Thanks!
January 15, 2023 at 8:08 pm #2496818Fernando Customer Support
Hi Henry,
You can add nth-of-type to your CSS selector. Example:
.main-navigation li:nth-of-type(1) { border: 1px solid #000; }This selects just the first instance of the selector. You can learn more here: https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-of-type
January 15, 2023 at 8:14 pm #2496822Henry
Thanks for the very fast reply, Fernando! So, I would create a class like “bordered” to show the border, so using your code it would look like this:
.main-navigation li:bordered { border: 1px solid #000; }^ And then add the class “bordered” to the CSS selector for the desired menu item in WordPress Menu?
January 15, 2023 at 8:19 pm #2496824Fernando Customer Support
Good idea. That should work too. It would be something like this:
.main-navigation li.bordered { border: 1px solid #000; }.precedes a class.January 15, 2023 at 8:20 pm #2496825Henry
(Below reply came in a mid-air collision with your reply)
Ah yes, I see what you are referring to for: “li:nth-of-type(1)” (basically the child menu items)
Yes that is helpful but not what I am trying to achieve – I’d like to ONLY add the border effect to certain menu items…..
Can you think of CSS that would make that happen?
Thanks!
January 15, 2023 at 8:20 pm #2496826Henry
Thanks I’ll try it out
January 15, 2023 at 8:21 pm #2496829Fernando Customer Support
You’re welcome, Henry! Let us know how it goes.
-
AuthorPosts
- You must be logged in to reply to this topic.