首先在css文件中写入
@font-face {
font-family: '汉真广标',"SalesforceSansRegular";
src: url('../font/汉真广标2.ttf') ;
}
再在类中引入
.kc-name{
font-size: 18px;
color:red;
font-family: '汉真广标';
}
特殊字体别忘记考虑浏览器兼容性
字体后缀和浏览器有关,如下所示
* .TTF或.OTF,适用于Firefox 3.5、Safari、Opera
* .EOT,适用于Internet Explorer 4.0+
* .SVG,适用于Chrome、IPhone
比如:
@font-face {
font-family: 'HansHandItalic';
src: url('fonts/hanshand-webfont.eot');
src: url('fonts/hanshand-webfont.eot?#iefix') format('embedded-opentype'),
url('fonts/hanshand-webfont.woff') format('woff'),
url('fonts/hanshand-webfont.ttf') format('truetype'),
url('fonts/hanshand-webfont.svg#webfont34M5alKg') format('svg');
font-weight: normal;
font-style: normal;
}
参考链接 :https://blog.csdn.net/qq_20757489/article/details/85059783