多个@ Font-Face

时间:2013-02-27 08:21:55

标签: css

我想在一个主css文件中加载项目@ font-face中的多个@ font-face。我下载了文件woff,但它们没有加载到网页中。如何将font-face用于本地文件?

@font-face {
  font-family: 'Ubuntu';
  font-style: normal;
  font-weight: 400;
  src: url('../Fonts/font1.woff');
  src: local('☺'), 
  url('font1.woff') format('woff');
}
@font-face {
  font-family: 'Ubuntu';
  font-style: normal;
  font-weight: 700;
  src: "../Fonts/font2.woff";
}

1 个答案:

答案 0 :(得分:1)

此解决方案是crossbrowser,适用于本地字体:

@font-face {
    font-family: "Exo";
    font-style: normal;
    font-weight: 400;
    src: url("/font/exo/Exo-Regular-webfont.eot?#iefix") format("embedded-opentype"),
         url("/font/exo/Exo-Regular-webfont.woff") format("woff"),
         url("/font/exo/Exo-Regular-webfont.ttf") format("truetype"),
         url("/font/exo/Exo-Regular-webfont.eot"), local("Exo-Regular"), 
         url("/font/exo/Exo-Regular-webfont.svg#ExoRegular") format("svg");
}

@font-face {
    font-family: "Exo";
    font-style: normal;
    font-weight: 700;
    src: url("/font/exo/Exo-DemiBold-webfont.eot?#iefix") format("embedded-opentype"),
    url("/font/exo/Exo-DemiBold-webfont.woff") format("woff"),
    url("/font/exo/Exo-DemiBold-webfont.ttf") format("truetype"),
    url("/font/exo/Exo-DemiBold-webfont.eot"), local("Exo-Bold"),
    url("/font/exo/Exo-DemiBold-webfont.svg#ExoDemiBold") format("svg");
}

您可以添加其他字体,但要注意页面加载时间。