简体   繁体   English

CSS覆盖'font-weight'属性

[英]CSS overriding for 'font-weight' property

I'm facing a strange problem with CSS overriding of 'font-weight' property. 我正面临一个CSS覆盖'font-weight'属性的奇怪问题。 Given below is the code showing the issue:- 以下是显示问题的代码: -

'font-weight' for element 'p' is set to small (in the same way color set to purple). 元素'p'的'font-weight'设置为小(与颜色设置为紫色的方式相同)。 But font is still rendering as bold on FF/Chrome, while color overrides to purple. 但是FF / Chrome上的字体仍然呈现为粗体,而颜色则覆盖为紫色。

Any idea why this is happening? 知道为什么会这样吗?

 p { font-weight: small; color: purple; } #speciality_test { font-weight: bold; color: red; } .class_speciality_test { font-weight: bold; color: red; } 
 <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> </head> <body> <div id="speciality_test"> <p> Inside identifier... HTML CSS test pages. </p> </div> <div class="class_speciality_test"> <p> Inside class... HTML CSS test pages. </p> </div> </body> </html> 

There's no font-weight:small; 没有font-weight:small; . I think you mean font-weight:normal; 我认为你的意思是font-weight:normal; or font-size:small; 或者font-size:small; .

See also CSS Fonts Module Level 3: 3.2 Font weight: the font-weight property . 另请参见CSS字体模块级别3:3.2字体粗细:font-weight属性

font-weight cannot be small . font-weight不能small It's either bold or normal . 它要么是bold的,要么是normal So your declaration is just ignored. 所以你的声明被忽略了。

See possible values here: http://www.w3schools.com/cssref/pr_font_weight.asp 请在此处查看可能的值: http//www.w3schools.com/cssref/pr_font_weight.asp

Is small a valid value? small有效值吗? According to W3C, it should be one of normal , bold , bolder , lighter , inherit or a number. 根据W3C,它应该是normalboldbolderlighterinherit或者数字。

I dont think small is valid. 我不认为小有效。

font-weight: normal;

is what i use at work 是我在工作中使用的

As far as I know, small is not a valid value for font-weight 据我所知, small不是font-weight的有效值

font-weight: { 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | bold | bolder | lighter | normal | inherit } ;

So in your example, the font-weight from the #speciality_test is used. 因此,在您的示例中,使用#speciality_test的font-weight。

Sitepoint reference Sitepoint参考

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM