[Resolved] Adding Sub Menu Hover Underline Animation

Home Forums Support [Resolved] Adding Sub Menu Hover Underline Animation

Home Forums Support Adding Sub Menu Hover Underline Animation

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #467631
    Muzaffar

    Hi,

    I wanted to have menu + submenu hover underline effect for my website and added css as on this link https://docs.generatepress.com/article/adding-menu-hover-animation/

    —————————Start of CSS Custom Code ————————
    /* nav links effect – Underline */

    @media
    (min-width:769px) {
    .main-navigation .menu > .menu-item > a::after {
    content: “”;
    position: absolute;
    right: 0;
    left: 55%;
    bottom: 12px;
    -webkit-transform: translateX(-50%);
    transform: translateX(-45%);

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

    background-color: currentColor;
    transition: 0.3s width ease;
    }
    .main-navigation .menu > .menu-item.current-menu-item > a::after,
    .main-navigation .menu > .menu-item > a:hover::after {
    width: 50%;
    }
    ———————–End of CSS Code ——————————

    The hover effect for main menu items looking great but there is one issue, the sub menu items are not effected by this change.

    I also want to have underline hover effect for my sub menu items.

    Please let me know the changes in my CSS code?

    Thanks
    Muzaffar

    GeneratePress 2.0.1
    GP Premium 1.5.6
    #467736
    Leo
    Staff
    Customer Support
    #468241
    Muzaffar

    Hi,

    Thanks it did work but not completely. Please see my website.

    There are two things to be resolved:

    1) Dropdown menu item underline is cross through the sub menu name. How to set it?

    2) The current / active main menu item should also be underlined when its dropdown item is underlined.

    Please help me to resolve this.

    Thank you
    Muzaffar

    This is my current code:
    /* nav links effect – Underline */

    @media
    (min-width:769px) {
    .main-navigation .menu .menu-item > a::after {
    content: “”;
    position: absolute;
    right: 0;
    left: 55%;
    bottom: 12px;
    -webkit-transform: translateX(-50%);
    transform: translateX(-45%);

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

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

    #468541
    Tom
    Lead Developer
    Lead Developer

    You could try adding this CSS:

    .main-navigation .menu .sub-menu .menu-item > a:hover::after,
    .main-navigation .menu .sub-menu .menu-item.current-menu-item > a::after {
        bottom: 0;
        left: 20px;
        transform: translateX(0);
        width: calc(100% - 40px);
    }
    #469292
    Muzaffar

    Thanks a lot Tom. You are great.

    Just one more thing, as pointed out in my above post. The current / active main menu item should also be underlined when its dropdown item is underlined or active.

    I will appreciate your help.

    Thank you
    Muzaffar

    #469382
    Tom
    Lead Developer
    Lead Developer

    Edited the code above ๐Ÿ™‚

    #469790
    Muzaffar

    Hi Tom,

    The main menu item still not showing underline when its dropdown menu item is underlined. I have copied the CSS code same as you edited.

    Your help is highly appreciated.

    Thanks
    Muzaffar

    #470085
    Tom
    Lead Developer
    Lead Developer
    #471068
    Muzaffar

    Hi Tom,

    Sorry, it is not underlining main menu items. Even not on hover. Previously it was underlining on hover.

    I didn’t update my live website. Checked on local website.

    Please fix the issue.

    Thank you
    Muzaffar

    #471069
    Muzaffar

    Hi Tom,

    Sorry, it is not underlining main menu items. Even not on hover. Previously it was underlining on hover.

    I didn’t update my live website. Checked on local website.

    Please fix the issue.

    Thank you
    Muzaffar

    #471104
    Tom
    Lead Developer
    Lead Developer

    Ah sorry about that – just updated it.

    #471115
    Muzaffar

    Hi Tom,

    Sorry I am confused. I am using following CSS, can you please make the changes in my following code for things work for me.

    Thanks
    Muzaffar

    ———– Current CSS Live Code ———————
    /* nav links effect – Underline */

    @media
    (min-width:769px) {
    .main-navigation .menu .menu-item > a::after {
    content: “”;
    position: absolute;
    right: 0;
    left: 55%;
    bottom: 12px;
    -webkit-transform: translateX(-50%);
    transform: translateX(-45%);

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

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

    .main-navigation .menu .sub-menu .menu-item > a:hover::after,
    .main-navigation .menu .sub-menu .menu-item.current-menu-item > a::after {
    bottom: 0;
    left: 20px;
    transform: translateX(0);
    width: calc(100% – 40px);
    }
    }
    ————– End of CSS ———————-

    #471498
    Tom
    Lead Developer
    Lead Developer

    Replace:

    .main-navigation .menu .menu-item.current-menu-item > a::after,
    .main-navigation .menu .menu-item > a:hover::after {
        width: 50%;
    }

    With:

    .main-navigation .menu > .menu-item.current-menu-item > a::after,
    .main-navigation .menu > .menu-item.current-menu-ancestor > a::after,
    .main-navigation .menu > .menu-item > a:hover::after {
        width: 50%;
    }
    #471513
    Muzaffar

    Thanks a lot Tom.

    It is resolved.

    #471530
    Tom
    Lead Developer
    Lead Developer
Viewing 15 posts - 1 through 15 (of 19 total)
  • You must be logged in to reply to this topic.