'font-weight'属性的 CSS 覆盖



我遇到了一个奇怪的问题,CSS覆盖了'font-weight'属性。以下是显示问题的代码:-

元素'p'的'font-weight'设置为small(与颜色设置为紫色相同)。但在FF/Chrome上,字体仍然呈现为粗体,而颜色覆盖为紫色。

知道为什么会发生这种事吗?

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>

没有font-weight:small;。我想你指的是font-weight:normal;font-size:small;

另请参阅CSS字体模块级别3:3.2字体重量:字体重量属性。

font-weight不能是small。它是boldnormal。所以你的声明被忽略了。

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

small是有效值吗?根据W3C,它应该是normalboldbolderlighterinherit中的一个或一个数字。

我认为small是无效的。

font-weight: normal;

是我在工作中使用的

据我所知,small不是font-weight 的有效值

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

因此,在您的示例中,使用了来自#speciality_test的字体权重。

站点点参考

最新更新