Wait for fonts to load before rendering web page

后端 未结 11 1367
终归单人心
终归单人心 2020-11-27 15:38

I\'m using @font-face to embed fonts in my website. First the text renders as the system default, and then (once the font file has loaded presumably) the correct font render

11条回答
  •  星月不相逢
    2020-11-27 16:16

    This is down to how the browser behaves.

    First off where is your @font declared? Is it inline to your HTML, declared in a CSS sheet on the page, or (hopefully) declared in an external CSS sheet?

    If it is not in an external sheet, try moving it to one (this is better practice anyway usually).

    If this doesn't help, you need to ask yourself is the fraction of a second difference really significantly detrimental to the user experience? If it is, then consider JavaScript, there are a few things you might be able to do, redirects, pauses etc, but these might actually be worse than the original problem. Worse for users, and worse to maintain.

    This link might help:

    http://paulirish.com/2009/fighting-the-font-face-fout/

提交回复
热议问题