谷歌修改了它的材质设计图标,有4个新的预设主题:

除了常规的填充/基线主题之外,概述,圆形,双色和锐:


但是,不幸的是,它没有说明如何使用新的主题。


我一直在通过谷歌Web字体使用它,包括链接:

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

然后使用文档中建议的所需图标:

<i class="material-icons">account_balance</i>

但它总是显示“填充/基线”版本。


我尝试了以下方法来使用outline主题:

<i class="material-icons">account_balance_outlined</i>
<i class="material-icons material-icons-outlined">account_balance</i>

并且,更改Web字体链接为:

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

等。但这并不奏效。


这样瞎猜是没有意义的。


有人尝试过使用新的主题吗?它甚至像基线版本(内联html标签)一样工作吗?或者,它只能以SVG或PNG格式下载吗?


当前回答

截至2019年2月27日,新的材质图标主题有CSS字体。

但是,您必须创建CSS类来使用字体。

字体系列如下:

材料图标轮廓-轮廓图标 材质图标双色-双色图标 圆形的图标 材质图标锐利-锐利的图标

请看下面的示例代码:

body { font-family: Roboto, sans-serif; } .material-icons-outlined, .material-icons.material-icons--outlined, .material-icons-two-tone, .material-icons.material-icons--two-tone, .material-icons-round, .material-icons.material-icons--round, .material-icons-sharp, .material-icons.material-icons--sharp { font-weight: normal; font-style: normal; font-size: 24px; line-height: 1; letter-spacing: normal; text-transform: none; display: inline-block; white-space: nowrap; word-wrap: normal; direction: ltr; -webkit-font-feature-settings: 'liga'; -webkit-font-smoothing: antialiased; } .material-icons-outlined, .material-icons.material-icons--outlined { font-family: 'Material Icons Outlined'; } .material-icons-two-tone, .material-icons.material-icons--two-tone { font-family: 'Material Icons Two Tone'; } .material-icons-round, .material-icons.material-icons--round { font-family: 'Material Icons Round'; } .material-icons-sharp, .material-icons.material-icons--sharp { font-family: 'Material Icons Sharp'; } <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500|Material+Icons|Material+Icons+Outlined|Material+Icons+Two+Tone|Material+Icons+Round|Material+Icons+Sharp"> </head> <body> <section id="original"> <h2>Baseline</h2> <i class="material-icons">home</i> <i class="material-icons">assignment</i> </section> <section id="outlined"> <h2>Outlined</h2> <i class="material-icons-outlined">home</i> <i class="material-icons material-icons--outlined">assignment</i> </section> <section id="two-tone"> <h2>Two tone</h2> <i class="material-icons-two-tone">home</i> <i class="material-icons material-icons--two-tone">assignment</i> </section> <section id="rounded"> <h2>Rounded</h2> <i class="material-icons-round">home</i> <i class="material-icons material-icons--round">assignment</i> </section> <section id="sharp"> <h2>Sharp</h2> <i class="material-icons-sharp">home</i> <i class="material-icons material-icons--sharp">assignment</i> </section> </body> </html>

或者在Codepen上查看


编辑:截至2019年3月10日,似乎现在有了新的字体图标类:

body { font-family: Roboto, sans-serif; } <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500|Material+Icons|Material+Icons+Outlined|Material+Icons+Two+Tone|Material+Icons+Round|Material+Icons+Sharp"> </head> <body> <section id="original"> <h2>Baseline</h2> <i class="material-icons">home</i> <i class="material-icons">assignment</i> </section> <section id="outlined"> <h2>Outlined</h2> <i class="material-icons-outlined">home</i> <i class="material-icons-outlined">assignment</i> </section> <section id="two-tone"> <h2>Two tone</h2> <i class="material-icons-two-tone">home</i> <i class="material-icons-two-tone">assignment</i> </section> <section id="rounded"> <h2>Rounded</h2> <i class="material-icons-round">home</i> <i class="material-icons-round">assignment</i> </section> <section id="sharp"> <h2>Sharp</h2> <i class="material-icons-sharp">home</i> <i class="material-icons-sharp">assignment</i> </section> </body> </html>

编辑#2:这是一个通过使用CSS图像过滤器来着色双色图标的变通方法(代码改编自此评论):

body { font-family: Roboto, sans-serif; } .material-icons-two-tone { filter: invert(0.5) sepia(1) saturate(10) hue-rotate(180deg); font-size: 48px; } .material-icons, .material-icons-outlined, .material-icons-round, .material-icons-sharp { color: #0099ff; font-size: 48px; } <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500|Material+Icons|Material+Icons+Outlined|Material+Icons+Two+Tone|Material+Icons+Round|Material+Icons+Sharp"> </head> <body> <section id="original"> <h2>Baseline</h2> <i class="material-icons">home</i> <i class="material-icons">assignment</i> </section> <section id="outlined"> <h2>Outlined</h2> <i class="material-icons-outlined">home</i> <i class="material-icons-outlined">assignment</i> </section> <section id="two-tone"> <h2>Two tone</h2> <i class="material-icons-two-tone">home</i> <i class="material-icons-two-tone">assignment</i> </section> <section id="rounded"> <h2>Rounded</h2> <i class="material-icons-round">home</i> <i class="material-icons-round">assignment</i> </section> <section id="sharp"> <h2>Sharp</h2> <i class="material-icons-sharp">home</i> <i class="material-icons-sharp">assignment</i> </section> </body> </html>

或者在Codepen上查看

其他回答

新的主题可能还不是Material Icons字体的一部分。链接。

Aj334最近的编辑工作完美。

谷歌CDN

<link href="https://fonts.googleapis.com/css?family=Material+Icons|Material+Icons+Outlined|Material+Icons+Two+Tone|Material+Icons+Round|Material+Icons+Sharp" rel="stylesheet">

图标元素

<i class="material-icons">donut_small</i>
<i class="material-icons-outlined">donut_small</i>
<i class="material-icons-two-tone">donut_small</i>
<i class="material-icons-round">donut_small</i>
<i class="material-icons-sharp">donut_small</i>

有点滑稽的是,谷歌制作了一种在Safari中正常工作但在Chrome中不正常的字体。这里是https://codepen.io/anon/pen/zbavza

<i class="material-icons-round red">warning</i>

参考https://stackoverflow.com/a/54902967/4740291,不能改变使用css的颜色。

截至2019年2月27日,新的材质图标主题有CSS字体。

但是,您必须创建CSS类来使用字体。

字体系列如下:

材料图标轮廓-轮廓图标 材质图标双色-双色图标 圆形的图标 材质图标锐利-锐利的图标

请看下面的示例代码:

body { font-family: Roboto, sans-serif; } .material-icons-outlined, .material-icons.material-icons--outlined, .material-icons-two-tone, .material-icons.material-icons--two-tone, .material-icons-round, .material-icons.material-icons--round, .material-icons-sharp, .material-icons.material-icons--sharp { font-weight: normal; font-style: normal; font-size: 24px; line-height: 1; letter-spacing: normal; text-transform: none; display: inline-block; white-space: nowrap; word-wrap: normal; direction: ltr; -webkit-font-feature-settings: 'liga'; -webkit-font-smoothing: antialiased; } .material-icons-outlined, .material-icons.material-icons--outlined { font-family: 'Material Icons Outlined'; } .material-icons-two-tone, .material-icons.material-icons--two-tone { font-family: 'Material Icons Two Tone'; } .material-icons-round, .material-icons.material-icons--round { font-family: 'Material Icons Round'; } .material-icons-sharp, .material-icons.material-icons--sharp { font-family: 'Material Icons Sharp'; } <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500|Material+Icons|Material+Icons+Outlined|Material+Icons+Two+Tone|Material+Icons+Round|Material+Icons+Sharp"> </head> <body> <section id="original"> <h2>Baseline</h2> <i class="material-icons">home</i> <i class="material-icons">assignment</i> </section> <section id="outlined"> <h2>Outlined</h2> <i class="material-icons-outlined">home</i> <i class="material-icons material-icons--outlined">assignment</i> </section> <section id="two-tone"> <h2>Two tone</h2> <i class="material-icons-two-tone">home</i> <i class="material-icons material-icons--two-tone">assignment</i> </section> <section id="rounded"> <h2>Rounded</h2> <i class="material-icons-round">home</i> <i class="material-icons material-icons--round">assignment</i> </section> <section id="sharp"> <h2>Sharp</h2> <i class="material-icons-sharp">home</i> <i class="material-icons material-icons--sharp">assignment</i> </section> </body> </html>

或者在Codepen上查看


编辑:截至2019年3月10日,似乎现在有了新的字体图标类:

body { font-family: Roboto, sans-serif; } <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500|Material+Icons|Material+Icons+Outlined|Material+Icons+Two+Tone|Material+Icons+Round|Material+Icons+Sharp"> </head> <body> <section id="original"> <h2>Baseline</h2> <i class="material-icons">home</i> <i class="material-icons">assignment</i> </section> <section id="outlined"> <h2>Outlined</h2> <i class="material-icons-outlined">home</i> <i class="material-icons-outlined">assignment</i> </section> <section id="two-tone"> <h2>Two tone</h2> <i class="material-icons-two-tone">home</i> <i class="material-icons-two-tone">assignment</i> </section> <section id="rounded"> <h2>Rounded</h2> <i class="material-icons-round">home</i> <i class="material-icons-round">assignment</i> </section> <section id="sharp"> <h2>Sharp</h2> <i class="material-icons-sharp">home</i> <i class="material-icons-sharp">assignment</i> </section> </body> </html>

编辑#2:这是一个通过使用CSS图像过滤器来着色双色图标的变通方法(代码改编自此评论):

body { font-family: Roboto, sans-serif; } .material-icons-two-tone { filter: invert(0.5) sepia(1) saturate(10) hue-rotate(180deg); font-size: 48px; } .material-icons, .material-icons-outlined, .material-icons-round, .material-icons-sharp { color: #0099ff; font-size: 48px; } <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500|Material+Icons|Material+Icons+Outlined|Material+Icons+Two+Tone|Material+Icons+Round|Material+Icons+Sharp"> </head> <body> <section id="original"> <h2>Baseline</h2> <i class="material-icons">home</i> <i class="material-icons">assignment</i> </section> <section id="outlined"> <h2>Outlined</h2> <i class="material-icons-outlined">home</i> <i class="material-icons-outlined">assignment</i> </section> <section id="two-tone"> <h2>Two tone</h2> <i class="material-icons-two-tone">home</i> <i class="material-icons-two-tone">assignment</i> </section> <section id="rounded"> <h2>Rounded</h2> <i class="material-icons-round">home</i> <i class="material-icons-round">assignment</i> </section> <section id="sharp"> <h2>Sharp</h2> <i class="material-icons-sharp">home</i> <i class="material-icons-sharp">assignment</i> </section> </body> </html>

或者在Codepen上查看

如果你已经在你的web项目中使用了材质图标,只需要更新html文件中的引用和图标使用的类:

html引用:

之前

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

<link href="https://fonts.googleapis.com/css?family=Material+Icons|Material+Icons+Outlined|Material+Icons+Two+Tone|Material+Icons+Round|Material+Icons+Sharp"
rel="stylesheet" />

材质图标类:

之后,检查你使用的className:

之前:

<i className="material-icons">weekend</i>

后:

<i className="material-icons-outlined">weekend</i>

这对我很有用……对于维达!