【问题标题】:Rounded Material Icons border and color problemRounded Material Icons 边框和颜色问题
【发布时间】:2026-01-21 23:45:01
【问题描述】:

我已将 Material Icons 包含在我的网页中,如下所示:

<link href="https://fonts.googleapis.com/icon?family=Material+Icons|Material+Icons+Round" rel="stylesheet">

我有圆角类的 css 代码

.material-icons.material-icons--rounded {
  font-family: 'Material Icons Round';
}

在页面中,星形图标如下所示:

如果我增加字体大小,它会变成这样:

该边框来自哪里以及如何删除它?

编辑:我创建了一支笔来重现问题https://codepen.io/anon/pen/wOJdMZ

@import "https://fonts.googleapis.com/icon?family=Material+Icons|Material+Icons+Round";
.material-icons--rounded {
  font-family: "Material Icons Round";
}
i {
   color: red;
}

.material-icons {
  font-size: 60px;
}

.size--2 {
  font-size: 90px;
}
<table>
  <tr>
    <th>Rounded</th>
    <td><i class="material-icons material-icons--rounded">star</i></td>
    <td><i class="material-icons material-icons--rounded size--2">star</i></td>
    <td><i class="material-icons material-icons--rounded">star_half</i></td>
    <td><i class="material-icons material-icons--rounded size--2">star_half</i></td>
    <td><i class="material-icons material-icons--rounded">star_border</i></td>
    <td><i class="material-icons material-icons--rounded size--2">star_border</i></td>
  </tr>
  <tr>
    <th>Not Rounded<br>
      <td><i class="material-icons">star</i></td>
      <td><i class="material-icons size--2">star</i></td>
      <td><i class="material-icons">star_half</i></td>
      <td><i class="material-icons size--2">star_half</i></td>
      <td><i class="material-icons">star_border</i></td>
      <td><i class="material-icons size--2">star_border</i></td>
  </tr>
</table>

更新: 圆角图标颜色在某些屏幕尺寸上没有变化。

我已更新问题所附的代码 sn-p。

  • 在 1920x1080 显示器上,所有图标都是红色的。
  • 在 2560 x 1600 的 macbook 视网膜屏幕上,圆形图标为黑色,其他图标为红色。 (这在 Chrome 或 Firefox 上似乎不是问题)

更新 2

颜色问题没有解决。 在视网膜屏幕上,图标没有任何颜色。 它们总是黑色的。 需要这方面的帮助。

【问题讨论】:

  • 能否提供相关的 HTML/CSS 以便于分析?没有上下文,调试起来有点困难
  • 当然,我添加了一个codepen链接
  • 谢谢,&lt;i&gt; 标签设置了 1px 的边框。您可以像这样删除它:i { border: 0; }for 所有 标记,或者通过将 .material-icons { border: 0;} 添加到样式表来使其更具体
  • @BillieBobbel 我再次更新了笔。看来&lt;i&gt; 没有边框。
  • 是的,我的错... Codepen 被缺少的分号弄糊涂了;但似乎@yunzen 发现这是由于一个破旧的字形......

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


【解决方案1】:

字形本身似乎有问题

如果您从这里下载 SVG 字形
https://material.io/tools/icons/?icon=star&style=round
在这里https://material.io/tools/icons/?icon=star&style=round

你可以看到rounded glyph是错误的,pointy star是正确的

你应该向https://github.com/material-components提出问题

给材料团队一些信息

路径是path("M 0 0 h 24 v 24 H 0 V 0 Z m 0 0 h 24 v 24 H 0 V 0 Z m 12 17.27 l 4.15 2.51 c 0.76 0.46 1.69 -0.22 1.49 -1.08 l -1.1 -4.72 l 3.67 -3.18 c 0.67 -0.58 0.31 -1.68 -0.57 -1.75 l -4.83 -0.41 l -1.89 -4.46 c -0.34 -0.81 -1.5 -0.81 -1.84 0 L 9.19 8.63 l -4.83 0.41 c -0.88 0.07 -1.24 1.17 -0.57 1.75 l 3.67 3.18 l -1.1 4.72 c -0.2 0.86 0.73 1.54 1.49 1.08 l 4.15 -2.5 Z");

&lt;svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 24 24" wtx-context="97FAD225-6CA6-4D16-A578-52C0523A648F"&gt;&lt;path d="M0 0h24v24H0V0zm0 0h24v24H0V0zm12 17.27l4.15 2.51c.76.46 1.69-.22 1.49-1.08l-1.1-4.72 3.67-3.18c.67-.58.31-1.68-.57-1.75l-4.83-.41-1.89-4.46c-.34-.81-1.5-.81-1.84 0L9.19 8.63l-4.83.41c-.88.07-1.24 1.17-.57 1.75l3.67 3.18-1.1 4.72c-.2.86.73 1.54 1.49 1.08l4.15-2.5z"/&gt;&lt;/svg&gt;

但应该是path("M 12 17.27 l 4.15 2.51 c 0.76 0.46 1.69 -0.22 1.49 -1.08 l -1.1 -4.72 l 3.67 -3.18 c 0.67 -0.58 0.31 -1.68 -0.57 -1.75 l -4.83 -0.41 l -1.89 -4.46 c -0.34 -0.81 -1.5 -0.81 -1.84 0 L 9.19 8.63 l -4.83 0.41 c -0.88 0.07 -1.24 1.17 -0.57 1.75 l 3.67 3.18 l -1.1 4.72 c -0.2 0.86 0.73 1.54 1.49 1.08 l 4.15 -2.5 Z")

&lt;svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 24 24" wtx-context="97FAD225-6CA6-4D16-A578-52C0523A648F"&gt;&lt;path d="M 12 17.27 l 4.15 2.51 c 0.76 0.46 1.69 -0.22 1.49 -1.08 l -1.1 -4.72 l 3.67 -3.18 c 0.67 -0.58 0.31 -1.68 -0.57 -1.75 l -4.83 -0.41 l -1.89 -4.46 c -0.34 -0.81 -1.5 -0.81 -1.84 0 L 9.19 8.63 l -4.83 0.41 c -0.88 0.07 -1.24 1.17 -0.57 1.75 l 3.67 3.18 l -1.1 4.72 c -0.2 0.86 0.73 1.54 1.49 1.08 l 4.15 -2.5 Z"/&gt;&lt;/svg&gt;

【讨论】:

  • 谢谢I have opened an issue,希望他们能尽快解决
  • +1ed 这个问题
  • 更新了问题先生,可能还有关于圆形图标颜色的另一个错误。
  • @Solhan 我没有看到您的第二个问题。你确定,你没有叉笔?
  • 我没有更新笔,我更新了问题附加的代码sn-p。
【解决方案2】:

问题是...您在两个类中都添加了字体大小。 我把它换成了一个新的类size--1

.size--1 {
  font-size: 60px;
}
.size--2 {
  font-size: 90px;
}
.material-icons--rounded {
  font-family: 'Material Icons Round;
}

material-icons 类不需要那种样式...(如果我理解正确的话,他正在应用图标)

HTML:

<i class="material-icons material-icons--rounded size--1">star</i>
<i class="material-icons material-icons--rounded size--2">star</i>

看到更新的笔... 我试过了

outline: none !important;
border: none !important; 
box-shadow: none !important;

这些都不起作用...
星星变成方形,从 font-size: 67px 开始......即使transform: scale(2,2) 也没有帮助。 rounded 类有问题))

【讨论】:

  • 谢谢,但如果我们在末尾添加.material-icons--rounded 类,图标不会四舍五入