font-family

介绍

设置自定义字体,可以是远程服务器字体、前端代码里的 Base64 编码的字体、客户端预注册的字体

语法

@font-face {
  [ font-family: <string>; ] ||
  [ src: url(<string>) | local(<string>); ]
}
1
2
3
4

示例

@font-face {
    font-family: 'myFont';
    src: url('data:application/x-font-woff;charset=utf-8;base64,base64编码'),
        url('https://www.runoob.com/try/demo_source/Sansation_Light.ttf');
}

text {
    font-family: 'myFont';
}
1
2
3
4
5
6
7
8
9
Last Updated: 2022/7/15 下午7:22:06