与CSS同步加载字体 [英] Load fonts synchronously with CSS
问题描述
我注意到在加载网页时,首先加载所有CSS文件,然后再加载所有字体.有没有一种方法可以使字体与样式表同时开始加载?
I noticed that when my web page was loading, all of the CSS files loaded first, then the fonts after all of those were done. Is there a way to make the fonts start loading at the same time as the stylesheets?
我正在使用@ font-face和一个网址.在样式表中对字体进行编码是否可以解决此问题?
I'm using @font-face with a url. Would encoding the font in the stylesheet solve this problem?
推荐答案
我还没有遇到过这种情况..我很喜欢在我的网页上使用嵌入式字体.就像我看到的那样使它们在网页加载时同步..我有一个font.css,我在其中嵌入了我需要的所有字体,像这样:
i haven't experienced this kind of scenario of yours..i'am fond of using embedded fonts on my webpages..i would like to share what i did as what i see to make them synch on web page load..i have a font.css where i embed all the fonts i needed like this:
@charset "utf-8";
/* CSS Document for Fonts :)*/
@font-face{
font-family: trajan;
src:url(../fonts/TrajanPro-Regular.otf);
}
并且url驻留在Web应用程序内的目录中..我只是将其链接到网页,然后直接在其他CSS上使用定义的字体..希望我明白了,并解释了正确的事情..谢谢您
and the url resides on the directory inside the web app..i just link this to the web page then use the defined font on other css directly..hope i got your point and explained the right thing..thank you
这篇关于与CSS同步加载字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!