Site logo

Archived topic

Menu Hover Animation does not work

7 replies · Started by Mihail on February 6, 2022

Viewing posts 1–8 of 8

Hi there,

can you share a link to the site so i can see what the problem is

Try this CSS instead:

@media (min-width: 769px) {
    .main-navigation .menu > li > a::after {
        content: "";
        position: absolute;
        right: 0;
        left: 50%;
        bottom: 15px;
        -webkit-transform: translate3d(-50%,0,0);
        transform: translate3d(-50%,0,0);

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

        background-color: currentColor;
        transition: 0.3s width ease;
    }
    .main-navigation .menu > li.current-menu-item > a::after,
    .main-navigation .menu > li.current-menu-ancestor > a::after,
    .main-navigation .menu > li > a:hover::after {
        width: 50%;
    }
}

Yes, it worked. Thank you! :)

But I have a question for the future: why doesn't the code from the documentation work for me?

The CSS in the documentation relies on the menu using the menu-items class. Whereas your menu is constructed of top level pages, which do not have those classes.

Try creating a Menu in Appearance > Menus to overcome that.

Ahh, I have this automatically created menu consisting of created pages...

Now I see what the problem was. I should have just created the menu manually.

Thanks for the help and information :)

Glad to be of help

This archived topic is closed to new replies.