使用Setup Method 2 self hosting为React项目安装谷歌材料图标与图标相关联的连字有时会显示在材料图标之前。
<i class="material-icons">face</i> {/* shows text "face" on site prior to proper material icon load */}例如,上面的代码行会显示" face“一秒钟,然后再显示一个”face“。我们如何延迟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');
}发布于 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:
<style>
@font-face {
font-family: 'Material Icons';
font-display: block;
}
</style>有关更多信息,请访问font-display
https://stackoverflow.com/questions/50911806
复制相似问题