@font-face won't load when visiting the site for the first time, must refresh/reload

旧街凉风 提交于 2019-12-10 17:53:16

问题


I've properly configured the CSS file using the http://www.fontsquirrel.com/fontface/generator kit generator and css codes, uploaded the font files in the right directory.

The fonts work perfectly fine on my website after refreshing once entered for the first time even while switching between pages, it's just that first time that the fonts don't show when entering the website until you refresh the page, happens in both Firefox and Chrome.

css code in the top of my CSS file:

@charset "utf-8";
body { margin:0; padding:0; width:100%; background:url(images/bg.png) repeat; }
html { padding:0; margin:0; }
a { text-decoration:none; border: none; outline:none; }
a:hover { text-decoration:underline; }
a img {border: none; }

@font-face{ font-family: 'handfont-webfont'; src: url('text/handfont-webfont.eot'); src: url('text/handfont-webfont.eot?#iefix') format('embedded-opentype'), url('text/handfont-webfont.woff') format('woff'), url('text/handfont-webfont.ttf') format('truetype'), url('text/handfont-webfont.svg#webfont') format('svg'); }

Here's the code of the font used for the paragraphs in my pages:

.body p { font-family:handfont-webfont; font-size: 12px; padding:5px 5px; margin:0; }

I tried looking for an answer but couldn't find one, would really appreciate any help guys.


回答1:


Have you tried to put the @font-face on top, before anything else in your CSS.

There is an error in your CSS:

.body p { font-family:handfont-webfont;}//there are no single quotes

Change it to:

.body p { font-family:'handfont-webfont';}//with single quotes



回答2:


try changing-

 font-family:'handfont-webfont' 

to

font:'handfont-webfont'

in .body p



来源:https://stackoverflow.com/questions/11929610/font-face-wont-load-when-visiting-the-site-for-the-first-time-must-refresh-re

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!