使用@font-face加载字体

使页面显示电脑没有的字体:

1.下载字体源文件,常用字体格式(.ttf,.eot,.otf,.woff);

注:如果找不到这么多格式的文件,可以使用在线字体格式转换器

2.定义字体

@font-face {
    font-family: myFont;
    src: url("../font/MNXLS.ttf"),
    url("../font/MNXLS.eot"),
    url("../font/MNXLS.otf"),
    url("../font/MNXLS.woff");
}

3.引用字体

.div_wenzi{
    font-family: myFont;
    font-size: 60px;
    text-align: center;
}

浏览器支持:

Firefox、Chrome、Safari 以及 Opera 支持 .ttf (True Type Fonts) 和 .otf (OpenType Fonts) 类型的字体。

Internet Explorer 9+ 支持新的 @font-face 规则,但是仅支持 .eot 类型的字体 (Embedded OpenType)。

注释:Internet Explorer 8 以及更早的版本不支持新的 @font-face 规则。

猜你喜欢

转载自blog.csdn.net/yilia_jia/article/details/85704050