1

我已经使用@font-face了一段时间,在线查看我的文件时没有任何问题。但@font-face从未在本地工作过。

我不明白为什么我不能@font-face在本地工作。我正在为我的开发人员使用 Visual Studio 2012 Ultimate。

CSS:

/* Include Fonts */
@font-face {
    font-family: 'SansationRegular';
    src: url('/Shared/Assets/Fonts/Sansation_Regular-webfont.eot');
    src: url('/Shared/Assets/Fonts/Sansation_Regular-webfont.eot?#iefix') format('embedded-opentype'),
         url('/Shared/Assets/Fonts/Sansation_Regular-webfont.woff') format('woff'),
         url('/Shared/Assets/Fonts/Sansation_Regular-webfont.ttf') format('truetype'),
         url('/Shared/Assets/Fonts/Sansation_Regular-webfont.svg#SansationRegular') format('svg');
    font-weight: normal;
    font-style: normal;

}

@font-face {
    font-family: 'SansationLight';
    src: url('/Shared/Assets/Fonts/Sansation_Light-webfont.eot');
    src: url('/Shared/Assets/Fonts/Sansation_Light-webfont.eot?#iefix') format('embedded-opentype'),
         url('/Shared/Assets/Fonts/Sansation_Light-webfont.woff') format('woff'),
         url('/Shared/Assets/Fonts/Sansation_Light-webfont.ttf') format('truetype'),
         url('/Shared/Assets/Fonts/Sansation_Light-webfont.svg#SansationLight') format('svg');
    font-weight: normal;
    font-style: normal;

}

@font-face {
    font-family: 'SansationBold';
    src: url('/Shared/Assets/Fonts/Sansation_Bold-webfont.eot');
    src: url('/Shared/Assets/Fonts/Sansation_Bold-webfont.eot?#iefix') format('embedded-opentype'),
         url('/Shared/Assets/Fonts/Sansation_Bold-webfont.woff') format('woff'),
         url('/Shared/Assets/Fonts/Sansation_Bold-webfont.ttf') format('truetype'),
         url('/Shared/Assets/Fonts/Sansation_Bold-webfont.svg#SansationBold') format('svg');
    font-weight: normal;
    font-style: normal;

}

@font-face {
    font-family: 'SansationLightLightItalic';
    src: url('/Shared/Assets/Fonts/Sansation_Light_Italic-webfont.eot');
    src: url('/Shared/Assets/Fonts/Sansation_Light_Italic-webfont.eot?#iefix') format('embedded-opentype'),
         url('/Shared/Assets/Fonts/Sansation_Light_Italic-webfont.woff') format('woff'),
         url('/Shared/Assets/Fonts/Sansation_Light_Italic-webfont.ttf') format('truetype'),
         url('/Shared/Assets/Fonts/Sansation_Light_Italic-webfont.svg#SansationLightLightItalic') format('svg');
    font-weight: normal;
    font-style: normal;

}

@font-face {
    font-family: 'SansationItalic';
    src: url('/Shared/Assets/Fonts/Sansation_Italic-webfont.eot');
    src: url('/Shared/Assets/Fonts/Sansation_Italic-webfont.eot?#iefix') format('embedded-opentype'),
         url('/Shared/Assets/Fonts/Sansation_Italic-webfont.woff') format('woff'),
         url('/Shared/Assets/Fonts/Sansation_Italic-webfont.ttf') format('truetype'),
         url('/Shared/Assets/Fonts/Sansation_Italic-webfont.svg#SansationItalic') format('svg');
    font-weight: normal;
    font-style: normal;

}

@font-face {
    font-family: 'SansationBoldItalic';
    src: url('/Shared/Assets/Fonts/Sansation_Bold_Italic-webfont.eot');
    src: url('/Shared/Assets/Fonts/Sansation_Bold_Italic-webfont.eot?#iefix') format('embedded-opentype'),
         url('/Shared/Assets/Fonts/Sansation_Bold_Italic-webfont.woff') format('woff'),
         url('/Shared/Assets/Fonts/Sansation_Bold_Italic-webfont.ttf') format('truetype'),
         url('/Shared/Assets/Fonts/Sansation_Bold_Italic-webfont.svg#SansationBoldItalic') format('svg');
    font-weight: normal;
    font-style: normal;

}

/* Set Fonts */
a, p, li, text, label, input, submit, textarea/* DEPRECATED:, #PositionPayRange*/ {
    font-family: 'SansationLight';
}

h1, h2, h3, h4, h5, h6, .PositionPayRange {
    font-family: 'SansationBold';
}

/* Font sizing */
a, p, li, label {
    font-size: small;

}

/* Set Font Colors */
a, p, li, text, label, input {
    color: #111111;
}

h1, h2, h3, h4, h5, h6 {
    color: #444444;
}

有人可以解释为什么它在服务器上工作得很好,但在本地却不行吗?

我使用哪个浏览器或哪个版本的浏览器都没有关系。结果相同。

编辑:

我的目录结构是:

root/
   Shared/
      Assets/
         Fonts/
            *fonts are in here.*
         CSS/
            * css files are in here. *
   Home.cshtml
4

2 回答 2

3

这应该适用于您当前的目录结构。

@font-face {
    font-family: 'SansationRegular';
    src: url('../Fonts/Sansation_Regular-webfont.eot');
    src: url('../Fonts/Sansation_Regular-webfont.eot?#iefix') format('embedded-opentype'),
         url('../Fonts/Sansation_Regular-webfont.woff') format('woff'),
         url('../Fonts/Sansation_Regular-webfont.ttf') format('truetype'),
         url('../Fonts/Sansation_Regular-webfont.svg#SansationRegular') format('svg');
    font-weight: normal;
    font-style: normal;

}

@font-face {
    font-family: 'SansationLight';
    src: url('../Fonts/Sansation_Light-webfont.eot');
    src: url('../Fonts/Sansation_Light-webfont.eot?#iefix') format('embedded-opentype'),
         url('../Fonts/Sansation_Light-webfont.woff') format('woff'),
         url('../Fonts/Sansation_Light-webfont.ttf') format('truetype'),
         url('../Fonts/Sansation_Light-webfont.svg#SansationLight') format('svg');
    font-weight: normal;
    font-style: normal;

}

@font-face {
    font-family: 'SansationBold';
    src: url('../Fonts/Sansation_Bold-webfont.eot');
    src: url('../Fonts/Sansation_Bold-webfont.eot?#iefix') format('embedded-opentype'),
         url('../Fonts/Sansation_Bold-webfont.woff') format('woff'),
         url('../Fonts/Sansation_Bold-webfont.ttf') format('truetype'),
         url('../Fonts/Sansation_Bold-webfont.svg#SansationBold') format('svg');
    font-weight: normal;
    font-style: normal;

}

@font-face {
    font-family: 'SansationLightLightItalic';
    src: url('../Fonts/Sansation_Light_Italic-webfont.eot');
    src: url('../Fonts/Sansation_Light_Italic-webfont.eot?#iefix') format('embedded-opentype'),
         url('../Fonts/Sansation_Light_Italic-webfont.woff') format('woff'),
         url('../Fonts/Sansation_Light_Italic-webfont.ttf') format('truetype'),
         url('../Fonts/Sansation_Light_Italic-webfont.svg#SansationLightLightItalic') format('svg');
    font-weight: normal;
    font-style: normal;

}

@font-face {
    font-family: 'SansationItalic';
    src: url('../Fonts/Sansation_Italic-webfont.eot');
    src: url('../Fonts/Sansation_Italic-webfont.eot?#iefix') format('embedded-opentype'),
         url('../Fonts/Sansation_Italic-webfont.woff') format('woff'),
         url('../Fonts/Sansation_Italic-webfont.ttf') format('truetype'),
         url('../Fonts/Sansation_Italic-webfont.svg#SansationItalic') format('svg');
    font-weight: normal;
    font-style: normal;

}

@font-face {
    font-family: 'SansationBoldItalic';
    src: url('../Fonts/Sansation_Bold_Italic-webfont.eot');
    src: url('../Fonts/Sansation_Bold_Italic-webfont.eot?#iefix') format('embedded-opentype'),
         url('../Fonts/Sansation_Bold_Italic-webfont.woff') format('woff'),
         url('../Fonts/Sansation_Bold_Italic-webfont.ttf') format('truetype'),
         url('../Fonts/Sansation_Bold_Italic-webfont.svg#SansationBoldItalic') format('svg');
    font-weight: normal;
    font-style: normal;

}
于 2013-04-24T07:53:13.887 回答
1

试试这样的路径

src: url('../Shared/Assets/Fonts/Sansation_Regular-webfont.eot');
于 2013-04-24T07:46:56.337 回答