admin管理员组

文章数量:1404347

There is a universal CSS class which does this:

.inside-article {
    background-color: #ffffff;
}

What I'd like to do is change the color to #393939 on a specific Post ID of 6238.

This doesn't seem to work:

.postid-6238 .inside-article {
background-color: #393939;
} 

Am I doing something wrong here?

Thanks!

There is a universal CSS class which does this:

.inside-article {
    background-color: #ffffff;
}

What I'd like to do is change the color to #393939 on a specific Post ID of 6238.

This doesn't seem to work:

.postid-6238 .inside-article {
background-color: #393939;
} 

Am I doing something wrong here?

Thanks!

Share Improve this question asked Jan 31, 2020 at 16:19 HenryHenry 9831 gold badge8 silver badges31 bronze badges 1
  • Try adding !important. – Vitauts Stočka Commented Jan 31, 2020 at 16:28
Add a comment  | 

1 Answer 1

Reset to default 0

This may not solve the problem necessary because there may be other rules in your theme that have higher specificity and will overrule your selectors but

You need to combine the selector together, like so:

.postid-6238.inside-article {
background-color: #393939;
} 

That selector will choose for all elements that have BOTH the classes .postid-6238 and .inside-article in them.

If you have them separated:

I've seen themes that will assign an id to the post-id instead of a class

本文标签: cssChange a div background color on Post ID