最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

css - Change a div background color on Post ID

programmeradmin4浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论