Site logo

Archived topic

CSS to set the width of dropdown menus to fit the widest menu item not working

5 replies · Started by Andrew on March 5, 2022

Viewing posts 1–6 of 6

Hello,

I'm trying to set the width of dropdown menus to fit the widest menu item (desktop only).

I tried using this CSS but it's not working. I'm not sure if I have other CSS that might be conflicting with it.

}
.main-navigation ul ul {
width: auto;
white-space: nowrap;
}

Hi there,

try giving it some importance:

@media(min-width: 1025px) {
    .main-navigation ul ul {
        width: auto !important;
        white-space: nowrap;
    }
}

And the media query is to stop it. messing up on mobile

Hi David - Thank you. That worked but I noticed on tablet the drop-down menu is now shifted to the left when I click on the menu items.

Perfect, thank you!!

You're welcome

This archived topic is closed to new replies.