Material Design图标
Google提供了免费的Material Design icon可以使用。github地址
使用Google API服务加载图标
引入CSS
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
使用图标
<i class="material-icons">face</i>
从本地加载图标字体
国内访问Google服务十分缓慢,因此建议从本地加载。
编写如下CSS:
/* fallback */
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: local('Material Icons'), local('MaterialIcons-Regular'), url(../fonts/md-font.woff2) format('woff2');
}
.material-icons {
font-family: 'Material Icons';
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;
-moz-font-feature-settings: 'liga';
-moz-osx-font-smoothing: grayscale;
}
注意url(../fonts/md-font.woff2),这个是字体文件的URL。woff2字体文件可以从Google API返回的CSS中获得,我们可以手动下载下来。
将字体文件加入我们的工程,并正确配置URL后,引入该CSS即可正常使用。
作者:Gacfox
版权声明:本网站为非盈利性质,文章如非特殊说明均为原创,版权遵循知识共享协议CC BY-NC-ND 4.0进行授权,转载必须署名,禁止用于商业目的或演绎修改后转载。