Site logo

Archived topic

dynamic menu button

6 replies · Started by Cynthia on January 22, 2023

Viewing posts 1–7 of 7

Is there a way within GP to create a dynamic hover effect for the menu buttons as shown in this website: https://anchorcm.net/

I hadn't started building my new site but my question applies to any website that I would build or have already built. Wouldn't the css you provide apply to any site?

If you could provide the css so that the menu buttons have the same hover effect that are on this site >>>> https://anchorcm.net/
that would be great!

I have provided one of my websites that I designed in the private field so I can test the css you provide on it.

Thank you

Wouldn’t the css you provide apply to any site?

It's usually not the case, we write CSS based on the site.

Try this, it should work for most GP sites.

.main-navigation .main-nav >ul > li:before {
    content: "";
    width: 0;
    position: absolute;
    left: 50%;
    top: 78%;
    background-color: orange;
    height: 2px;
    transition: 0.4s all ease;
}

.main-navigation .main-nav >ul > li:hover:before {
    left: 20px;
    width: calc(100% - 20px - 20px);
}

.main-navigation .main-nav >ul > li {
    position: relative;
}

It IS actually working on all of my client sites. Thank you !!

It IS actually working on all of my client sites. Thank you !

However is there a way to not have the effect applied to the mobile navigation while keeping the effect on the desktop?

Cynthia,

Yes, there's a way.

Try this code instead:

@media (min-width: 1025px) {
    .main-navigation .main-nav >ul > li:before {
        content: "";
        width: 0;
        position: absolute;
        left: 50%;
        top: 78%;
        background-color: orange;
        height: 2px;
        transition: 0.4s all ease;
    }

    .main-navigation .main-nav >ul > li:hover:before {
        left: 20px;
        width: calc(100% - 20px - 20px);
    }

    .main-navigation .main-nav >ul > li {
        position: relative;
    }
}

I just added an @media query to Ying's code to allow it to take effect only on Desktop view.

This archived topic is closed to new replies.