0

So I have this XML file to move the navigation:

<move element="navigation.sections" destination="header-wrapper" />

On Desktop, I need some styling to try and keep it between the logo and the search bar so I have added this CSS inside of a _navigation_extend.less file:

.nav-sections {
    background-color: transparent;
    position: relative;
    top: -12px;
    left: 10px;
    margin-bottom: 0px;
    width: 52%;
    float: left;
}
.navigation {
    background-color: transparent;
    font-weight: 400;
    z-index: 5;
}

This fixes my issue on desktop mode but completely breaks mobile navigation. How can I fix this on desktop mode and keep the current style for mobile?

1

I found some CSS being applied in the LESS file vendor/magento/theme-frontend-blank/Magento_Theme/web/css/source/_module.less and it shows how to apply CSS for the Desktop breakpoints. My new file looks like this:

// DESKTOP
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) {
    .nav-sections {
        background-color: transparent;
        position: relative;
        top: -12px;
        left: 10px;
        margin-bottom: 0px;
        width: 52%;
        float: left;
    }
    .navigation {
        background-color: transparent;
        font-weight: 400;
        z-index: 5;
    }
}

So all I really did was copy that breakpoint logic and put my CSS inside. Awesome!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.