admin管理员组文章数量:1387310
Can we apply css based on post category. For example I have below css
.question-content-text{font-size: 16px;}
This is applicable to all posts, my requirement is to have different css based on post category as follows
If (post_category_id = 1 ) then this css .question-content-text{font-size: 16px;}
If (post_category_id = 2 ) then this css .question-content-text{font-size: 25px;}
IF (post_category_id not in (1, 2) ) then this css .question-content-text{font-size: 50px;}
If its possible, Could you please help me to get this within my child theme
Can we apply css based on post category. For example I have below css
.question-content-text{font-size: 16px;}
This is applicable to all posts, my requirement is to have different css based on post category as follows
If (post_category_id = 1 ) then this css .question-content-text{font-size: 16px;}
If (post_category_id = 2 ) then this css .question-content-text{font-size: 25px;}
IF (post_category_id not in (1, 2) ) then this css .question-content-text{font-size: 50px;}
If its possible, Could you please help me to get this within my child theme
Share Improve this question asked Apr 15, 2020 at 13:53 Avinash PatelAvinash Patel 398 bronze badges 4- This totally depends on your theme. For example the Twenty Twenty theme has the category-<your-category> class added. – Tobias Commented Apr 15, 2020 at 13:57
- thanks @Tobias but can we achieve this if the theme doesn't have this already? – Avinash Patel Commented Apr 15, 2020 at 14:20
- What's your theme? – Tobias Commented Apr 15, 2020 at 17:40
- hi @Tobias its discy theme. – Avinash Patel Commented Apr 16, 2020 at 6:04
1 Answer
Reset to default 0Looks like the Discy theme also has the category in the classes like shown in the screenshot:
Simply add your styles to the class.
Example:
.question-category-language {
font-size: 16px;
}
.question-category-analytics {
font-size: 25px;
}
本文标签: functionsCan we have conditional CSS styling
版权声明:本文标题:functions - Can we have conditional CSS styling? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744557884a2612588.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论