Can you stop a CSS class on a particular URL?

HTML, CSS and anything else that deals with client side capabilities.

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Can you stop a CSS class on a particular URL?

Post by simonmlewis »

Is there a way in a CSS class, to say if URL does not contain /blog, then do this.... ?

We have a full width category page which is perfect in Wordpress, but it is also assigning that class width to the Blogs. We want the Blog to not be full width.

So I wondered if it can be set to

Code: Select all

body .archive .grve-container,#disqus_thread,#grve-content.grve-left-sidebar .grve-content-wrapper,#grve-content.grve-right-sidebar .grve-content-wrapper
{
    max-width: 89%!important;
    margin-right: auto;
    margin-left: auto;
}
.... when URL does not have /blog/ in it.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Can you stop a CSS class on a particular URL?

Post by requinix »

You can't have CSS target a URL.

If your next thought is about using classes or adding some CSS just for blog pages then you're on the right track.
baldwinjackson
Forum Newbie
Posts: 8
Joined: Wed Oct 18, 2017 2:58 am

Re: Can you stop a CSS class on a particular URL?

Post by baldwinjackson »

I guess there is 2 approach to do so. 1 you can assign a specify class on blog pages by over riding the blog function.php file then write the code in style.css file. If the pages are few like 2-3 then you pick page-id and apply the css on page-id:

#page-id .anyclass > .other > .finalclass

Cheers!
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: Can you stop a CSS class on a particular URL?

Post by Weirdan »

You can't have CSS target a URL.
Unless there's some JS that adds CSS classes based on the URL, like Modernizr does based on browser features.
Post Reply