[英]Overwriting CSS rules for specific areas
In my code, I have <p>
style at font-size 16px. 在我的代码中,我具有<p>
样式,字体大小为16px。
But, for a "card" I want to apply a font-size of 20px to any <p>
text in there, without applying a slightly larger font-class to each <p>
I may include. 但是,对于“卡片”,我想对其中的任何<p>
文本应用20px的字体大小,而不<p>
可能包括的每个<p>
应用稍大的字体类。
So that any "card" class across the site, will have the same overwritten 20px, instead of 16px. 这样,整个网站上的所有“卡片”类都将覆盖20px,而不是16px。
What is a "card"? 什么是“卡”? If it's just a div with class card: 如果只是带类卡的div:
.card {
font-size: 20px;
}
That will override the initial 16px if it is has higher specificity than the initial 16px. 如果其特异性高于初始16px,则它将覆盖初始16px。 Read up on CSS Specificity: https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity 阅读CSS专用性: https : //developer.mozilla.org/en-US/docs/Web/CSS/Specificity
I assume that you are using bootstrap class -> 'card'. 我假设您正在使用引导程序类->'card'。
.card p
{
font-size: 20px !important;
}
define above class in your stylesheet. 在样式表中定义以上类。 It will work smoothly , it will apply the mentioned font size in every p tag you use inside a class 'card' anywhere on your page. 它将正常运行,它将在页面上任何地方的“卡”类中使用的每个p标签中应用上述字体大小。
Good Luck. 祝好运。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.