Wait for fonts to load before rendering web page

后端 未结 11 1364
终归单人心
终归单人心 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 15:59

    This code works very well for me. It uses the Font Loading API which has good support among modern browsers.

    
    
    

    The trick is to set the CSS color to transparent for elements using the font. Once loaded this is reset by adding font-loaded class to element.

    Please replace DemoFont with something meaningful for your project to get it work.

提交回复
热议问题