【问题标题】:MaterialIcons-Regular as font bugs when any CSS *:first-letter is appliedMaterialIcons-Regular 应用任何 CSS *:first-letter 时的字体错误
【发布时间】:2018-07-04 10:37:26
【问题描述】:

如果我在此选择器上应用任何 CSS 规则,而在 Chrome 上,我的 MaterialIcons-Regular 图标会消失或分解成两个不同的图标。

 *:first-letter {
    color: #000 
}

知道这里可能有什么问题吗?

想看看我的意思吗?在 Firefox 和 Chrome 中打开的链接: https://jsfiddle.net/z7xmf81u/

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
</head>
<style>
*:first-letter {color: blue;}
h1   {color: blue;}
p    {color: red;}
</style>

<body>
<p>test</p>
<i class="material-icons">cloud</i>
<i class="material-icons" style="font-size:48px;">cloud</i>
<i class="material-icons" style="font-size:60px;color:red;">cloud</i>
<i class="material-icons" style="font-size:60px;color:red;">network_check</i>

</body>
</html>

你可以删除

*:首字母{颜色:蓝色;}

随意排队。

感谢任何解决方法,谢谢

【问题讨论】:

    标签: css google-chrome google-material-icons


    【解决方案1】:

    嗯...似乎是因为这是一种连字字体。

    当应用此伪元素时,cloud 变为 "cloud",这在 Mat-icons 中没有等效项。同样,network_check 变为 "network_check" 并且 可能 network 和 check 确实 具有 MI 等价物。也许*:not(.material-icons) 可能有用?

    *:not(.material-icons):first-letter {
      color: blue;
    }
    
    h1 {
      color: blue;
    }
    
    p {
      color: red;
    }
    <head>
      <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
    </head>
    
    
    <body>
      <p>test</p>
      <i class="material-icons">cloud</i>
      <i class="material-icons" style="font-size:48px;">cloud</i>
      <i class="material-icons" style="font-size:60px;color:red;">cloud</i>
      <i class="material-icons" style="font-size:60px;color:red;">network_check</i>
    
    </body>

    【讨论】:

    • 我这样做是为了解决这个问题。尽管如此,具有讽刺意味的是,谷歌字体在谷歌浏览器上失败了。这是我替换它的命令:sed -r -i -e 's/\*:first-letter/\*:not(.material-icons):first-letter/g' dummy.css
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-21
    • 2018-06-06
    • 1970-01-01
    • 1970-01-01
    • 2018-07-19
    • 2016-06-16
    相关资源
    最近更新 更多