[英]Preloading fonts in CSS File
i have a font-awesome CSS-Fille which i load in the footer of my website.我有一个字体很棒的 CSS-Fill,我将它加载到我网站的页脚中。 In the CSS File the fonts are loaded kike this:
在 CSS 文件中,字体是这样加载的:
font-display:swap;src:url(../webfonts/fa-brands-400.eot);src:url(../webfonts/fa-brands-400.eot?#iefix)
format("embedded-opentype"),url(../webfonts/fa-brands-400.woff2) format("woff2"),url(../webfonts/fa-
brands-400.woff) format("woff"),url(../webfonts/fa-brands-400.ttf)......
not i look for an solution to preload these fonts.我不是在寻找预加载这些字体的解决方案。 Is there an easy way to do that?
有没有简单的方法来做到这一点?
Not sure if thats what you mean, but you can define a font-face in a seperate css file, eg:不确定这是否是您的意思,但您可以在单独的 css 文件中定义字体,例如:
@font-face {
font-family: faBrands;
font-weight: 400;
src: url('/webfonts/fa-brands-400.eot');
}
@font-face {
font-family: faBrands;
font-weight: 400;
src: url('/webfonts/fa-brands-500.eot');
}
Assuming the folder webfonts
is under public
, you can then write in a css file:假设文件夹
webfonts
在public
下,您可以在 css 文件中写入:
font-family: faBrands;
Just make sure to import the font face css file first.只需确保先导入字体 css 文件即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.