开发中有些项目要求使用固定的字体,这就需要项目中使用字体库。
首先需要下载字体库
将下载的字体文件放进项目中
在项目代码样式文件中定义字体
@font-face { font-family: "Tobias-SemiBold"; src: url("./assets/font/Tobias-SemiBold.ttf"); font-weight: normal; font-style: normal; } @font-face { font-family: "Tobias-Regular"; src: url("./assets/font/Tobias-Regular.ttf"); font-weight: normal; font-style: normal; } 123456789101112
运用字体
html, body, #root { height: 100%; font-family: Tobias-Regular; } 1234