Hide views column everywhere except one category


(David Kingham) #1

I am trying to hide the views column everwhere except for a few categories where I want it visible. I first tried hiding it in the categories where I didn’t want to see it, but then I still want it hidden in latest/new/unread. So I figured I could use :not to hide it everywhere except the categories I want it visible, for example:

:not(body.category-discussions) {
    .topic-list .views {
        display: none;
    }
}

I also tried this:

.topic-list .views:not(body.category-discussions) {
	display: none;
}

Neither worked. I’m sure I’m missing some stupid simple syntax so forgive my newbness. Thanks!


(Joe) #2

This doesn’t work because a :not psudo-class when used without a simple selector already applies to the body tag and so the rule reads

body that is not body

:not(.category-discussions) on the other hand would have worked.

This doesn’t work because CSS works from top to bottom, so, in order for your rules to apply, you need to follow the order of the markup

try this and see if it works for you.

body:not(.category-discussions) .topic-list .views {
  display: none;
}

(David Kingham) #3

Thank you for the detailed explanation! That works brilliantly and really helped me understand :+1: