离线使用Google Material Icons

本文最后更新于(2023-2-23 09:32:17),链接可能失效,内容可能难以复现。请注意甄别。
引用:https://stackoverflow.com/questions/37270835/how-to-host-material-icons-offline
1. 前往https://github.com/google/material-design-icons/releases下载最新的Releases包。 2. 解压后,将font文件夹整个上传到你的站点根目录。 3. 添加网站对字体格式的支持,在.htaccess文件里加入以下代码:
<FilesMatch ".(eot|ttf|otf|woff|woff2)">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
4. 创建一个css文件,来定义字体,(最新版本里只有ttf和otf两种格式):

文件结构

@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url(iconfont/MaterialIcons-Regular.eot); /* For IE6-8 */
src: local('Material Icons'),
local('MaterialIcons-Regular'),
url(iconfont/MaterialIcons-Regular.woff2) format('woff2'),
url(iconfont/MaterialIcons-Regular.woff) format('woff'),
url(iconfont/MaterialIcons-Regular.ttf) format('truetype');
}

.material-icons {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 24px; /* Preferred icon size */
display: inline-block;
line-height: 1;
text-transform: none;
letter-spacing: normal;
word-wrap: normal;
white-space: nowrap;
direction: ltr;

/* Support for all WebKit browsers. */
-webkit-font-smoothing: antialiased;
/* Support for Safari and Chrome. */
text-rendering: optimizeLegibility;

/* Support for Firefox. */
-moz-osx-font-smoothing: grayscale;

/* Support for IE. */
font-feature-settings: 'liga';
}
5. 最后在HTML里调用图标 <span class="material-icons">face</span> 显示效果:
face

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

[smirking] [hentai] [wounded] [cracker] more »