Site logo

[Support request] How to create a colored border around the menue items in the primary navigation

Home Forums Support [Support request] How to create a colored border around the menue items in the primary navigation

Home Forums Support How to create a colored border around the menue items in the primary navigation

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #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

    #2212323
    David
    Staff
    Customer Support

    Hi there,

    this CSS will add a border to the menu item:

    .main-navigation li {
        border: 1px solid #fff;
    }
    #2212326
    martin

    Perfect! Thxs for your swift reply !

    rgds

    #2212340
    David
    Staff
    Customer Support

    You’re welcome

    #2496810
    Henry

    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!

    #2496818
    Fernando
    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

    #2496822
    Henry

    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?

    #2496824
    Fernando
    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.

    #2496825
    Henry

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

    #2496826
    Henry

    Thanks I’ll try it out

    #2496829
    Fernando
    Customer Support

    You’re welcome, Henry! Let us know how it goes.

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.