如何(以及如何不)加载使用@ font-face的css文件

时间:2015-03-20 09:14:56

标签: html css fonts webfonts

我试图从css文件中加载一些个人字体(@ font-face)。

如果我使用:

<link href="css/style.css" type="text/css" rel="stylesheet" media="all">

字体不会加载。

但是,使用:

<style>@import url('css/style.css');</style>

他们加载!

第一种方法是否也不行?这是我一直使用的那个......虽然这是我第一次使用@ font-face。

请注意,使用第一种方法,CSS应用得很好。它只是不加载的字体......

编辑:

我的CSS开头是这样的:

@font-face {
    font-family:'MyFont-Bold';
    src: url('../type/MyFont-Bold.eot');
    src: url('../type/MyFont-Bold.eot?#iefix') format('embedded-opentype'),
         url('../type/MyFont-Bold.woff') format('woff'),
         url('../type/MyFont-Bold.ttf') format('truetype'),
         url('../type/MyFont-Bold.svg#MyFont-Bold') format('svg');
    font-weight: 700;
    font-style: normal;
    font-stretch: normal;
    unicode-range: U+0020-2212;
}

1 个答案:

答案 0 :(得分:1)

创建font.css并在style.css @import(font.css)

请阅读第二个问题:http://www.htmldog.com/guides/css/advanced/atrules/