Site logo

Archived topic

Exclude one page (home page) from CSS rule?

5 replies · Started by Emil on January 6, 2021

Viewing posts 1–6 of 6

Hi!

I wanted the sidebar to not get smaller than 300px and got help to find this solution:

@media (min-width: 769px) {
#primary {
width: calc(100% - 330px);
}
#right-sidebar {
width: 330px;
}
}

It works perfect!

But the problem now is that I want the home page to be full width, without a sidebar. How can I exclude the homepage from this CSS code?

Or can I do it some other way?

Hi there,

you can change your CSS to exclude the home page:

@media (min-width: 769px) {
    body:not(.home) #primary {
        width: calc(100% – 330px);
    }

    body:not(.home) #right-sidebar {
        width: 330px;
    }
}

That code made the home page look good. But on all other pages with sidebar, the sidebar went down under the main content. Can you take a look at it, please?

/Emil

Try manually retyping this line - looks some weird spacing character got copied over:

width: calc(100% – 330px);

Great, that worked like a charm! Thank you!

Glad to hear that

This archived topic is closed to new replies.