网站上一些字体可能不是默认的 通过@font-face可以加载自己特定的字体 从而来实现特定的文字效果
1、定义一个自定义字体:
@font-face {
font-family: 'iconfont';/*声明一个名为iconfont的字体变量*/
src: url('../font/iconfont.eot');
src: url('../font/iconfont.eot?#iefix') format('embedded-opentype'),
url('../font/iconfont.woff2') format('woff2'),
url('../font/iconfont.woff') format('woff'),
url('../font/iconfont.ttf') format('truetype'),
url('../font/iconfont.svg#iconfont') format('svg');
}
2.字体后缀及其对应的格式
font-family属性:字体名称 自定义
url属性:自定义字体在当前服务器的位置(可填相对路径和绝对路径)
format属性:字体的格式 主要用于浏览器识别
通常有以下几种:truetype opentype truetype-aat embedded-opentype avg等
TrueType格式(.ttf)
Windows和Mac上常见的字体格式 这是一种原始格式