使用Setup Method 2 self hosting为我们的React项目安装Google Material图标,有时会在材质图标前显示与图标关联的连字。
<i class="material-icons">face</i> {/* shows text "face" on site prior to proper material icon load */}
例如,在显示面部之前,上面的线将显示“面部”一秒钟。在文件引用完全加载之前,我们如何延迟UI呈现?
/*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');
}
答案 0 :(得分:0)
来自How to prevent material icon text from showing up when Google's JS fails to convert them?的回答:
您可以使用 font-display: block;
,只需将此 CSS 添加到您的 HTML 头部即可:
<style>
@font-face {
font-family: 'Material Icons';
font-display: block;
}
</style>
了解更多信息font-display