css怎么把字体变细?

来自:互联网
时间:2019-11-11
阅读:

CSS 能够对网页中元素位置的排版进行像素级精确控制,支持几乎所有的字体字号样式,拥有对网页对象和模型样式编辑的能力。

在CSS中,通过 font-weight属性 用来设置字体的粗细值。

该属性用于设置显示元素的文本中所用的字体加粗。数字值 400 相当于 关键字 normal,700 等价于 bold。每个数字值对应的字体加粗必须至少与下一个最小数字一样细,而且至少与下一个最大数字一样粗。

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
.lighter {
font-weight: lighter;
}
.normal {
font-weight: normal;
}
.bold {
font-weight: bold;
}
.bolder {
font-weight: bolder;
}
   </style>
 </head>
  <body>
<p class="lighter">字体粗细:lighter</p>
<p class="normal">字体粗细:normal</p>
<p class="bold">字体粗细:bold</p>
<p class="bolder">字体粗细:bolder</p>
  </body>
</html>

效果如下:

1.jpg

font-weight 属性也可以直接设置数字100-900,定义由粗到细的字符。400 等同于 normal,而 700 等同于 bold。

font-weight 属性可能值:

2.jpg

返回顶部
顶部