Site logo

Archived topic

Nav Menu Hover Underline - Exclude Nav Button

3 replies · Started by Brent Wilson on January 24, 2023

Viewing posts 1–4 of 4

I have added a menu underline on hover. But I have also added a nav button. I don't want the underline on hover for the nav button. How can I exclude that item from underline?

Hi there,

Modify the menu hover underline CSS to this:

@media (min-width: 835px) {
    .main-navigation .menu > .menu-item:not(.nav-button) > a::after {
        content: "";
        position: absolute;
        right: 0;
        left: 50%;
        bottom: 12px;
        -webkit-transform: translate3d(-50%,0,0);
        transform: translate3d(-50%,0,0);

        display: block;
        width: 0;
        height: 1.5px;

        background-color: currentColor;
        transition: 0.2s width ease;
    }
    .main-navigation .menu > .menu-item.current-menu-item:not(.nav-button) > a::after,
    .main-navigation .menu > .menu-item.current-menu-ancestor:not(.nav-button) > a::after,
    .main-navigation .menu > .menu-item:not(.nav-button) > a:hover::after {
        width: 90%;
    }
}

That seems to work great! Thanks!

No problem :)

This archived topic is closed to new replies.