font-face在本地不起作用

时间:2013-04-24 07:41:25

标签: asp.net html css font-face

我一直在使用@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

2 个答案:

答案 0 :(得分: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;

}

答案 1 :(得分:1)

尝试这样的路径

src: url('../Shared/Assets/Fonts/Sansation_Regular-webfont.eot');