首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >google material图标加载缓慢,从文本到图标闪烁

google material图标加载缓慢,从文本到图标闪烁
EN

Stack Overflow用户
提问于 2018-06-18 22:31:59
回答 1查看 1.5K关注 0票数 12

使用Setup Method 2 self hosting为React项目安装谷歌材料图标与图标相关联的连字有时会显示在材料图标之前。

代码语言:javascript
复制
<i class="material-icons">face</i> {/* shows text "face" on site prior to proper material icon load */}

例如,上面的代码行会显示" face“一秒钟,然后再显示一个”face“。我们如何延迟UI渲染,直到文件引用完全加载?

代码语言:javascript
复制
/*material icons file references loaded locally */
    @font-face {
      font-family: 'Material Icons';
      font-style: normal;
      font-weight: 400;
      src: url(../node_modules/material-design-icons/iconfont/MaterialIcons-Regular.eot); /* For IE6-8 */
      src: local('Material Icons'), local('MaterialIcons-Regular'), url(../node_modules/material-design-icons/iconfont/MaterialIcons-Regular.woff2) format('woff2'), url(../node_modules/material-design-icons/iconfont/MaterialIcons-Regular.woff) format('woff'), url(../node_modules/material-design-icons/iconfont/MaterialIcons-Regular.ttf) format('truetype');
    }
EN

回答 1

Stack Overflow用户

发布于 2021-01-03 17:15:50

来自How to prevent material icon text from showing up when Google's JS fails to convert them?的答案

你可以使用font-display: block;,只需将这个CSS添加到你的head:

代码语言:javascript
复制
<style>
   @font-face {
      font-family: 'Material Icons';
      font-display: block;
    }
</style>

有关更多信息,请访问font-display

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50911806

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档