css - Change a div background color on Post ID

There is a universal CSS class which does this:.inside-article {background-color: #ffffff;}What I'd like to do is

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744786511a4593659.html

相关推荐

  • css - Change a div background color on Post ID

    There is a universal CSS class which does this:.inside-article {background-color: #ffffff;}What I'd like to do is

    16小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信