首页 话题 小组 问答 好文 用户 我的社区 域名交易 唠叨

[分享]css中 字体加粗的代码

发布于 2024-11-11 19:16:02
0
17

在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: ***;
    font-weight: 900; //更加粗 

我们可以将这些值应用于单个元素:

 p {
        font-weight: bold;
    } 

我们也可以将这些值应用于整个页面或全局CSS:

 body {
        font-weight: normal;
    } 

请注意,不是所有字体都支持所有

font-weight
值。

也可以使用

font-weight: inherit;
从父级继承字体加粗属性。此外,还有其他方法可以实现字体加粗,例如使用
strong
b
标签。

评论
一个月内的热帖推荐
91云脑
Lv.1普通用户

62849

帖子

14

小组

291

积分

赞助商广告
站长交流