在CSS中,我们可以通过指定 font-weight 属性来控制字体是否加粗。该属性接受以下值: font-weight: normal; //默认 font-weight: bold; //加粗 f
在CSS中,我们可以通过指定
font-weight属性来控制字体是否加粗。
该属性接受以下值:
font-weight: normal; //默认 font-weight: bold; //加粗 font-weight: bolder; //更加粗 font-weight: lighter; //更加细 font-weight: 100; font-weight: 200; font-weight: 300; font-weight: 400; //默认 font-weight: 500; font-weight: 600; font-weight: 700; //加粗 font-weight: 800; font-weight: 900; //更加粗
我们可以将这些值应用于单个元素:
p { font-weight: bold; }
我们也可以将这些值应用于整个页面或全局CSS:
body { font-weight: normal; }
请注意,不是所有字体都支持所有
font-weight值。
也可以使用
font-weight: inherit;从父级继承字体加粗属性。此外,还有其他方法可以实现字体加粗,例如使用
strong或
b标签。
粉丝
0
关注
0
收藏
0