CSS @font-face not working with Firefox, but working with Chrome and IE

后端 未结 28 2842
野趣味
野趣味 2020-11-22 06:27

The following code works in Google Chrome beta as well as IE 7. However, Firefox seems to have a problem with this. I\'m suspecting it to be a problem of how my CSS files ar

28条回答
  •  不要未来只要你来
    2020-11-22 06:40

    This is a problem with how you setup your font-face's paths. Since you didn't start the path with a "/", Firefox will attempt to find the font's based on the path the stylesheet's in. So basically, Firefox is looking for your font in the "root/css/font" directory instead of the "root/font" directory. You can easily fix this by either moving the font folder to the css folder, or adding a / to the beginning of your font paths.

    Try this out:

    @font-face {
        font-family: "DroidSerif Regular";
        src: url("/font/droidserif-regular-webfont.eot");
        src: local("DroidSerif Regular"), url("/font/droidserif-regular-webfont.woff") format("woff"), url("/font/droidserif-regular-webfont.ttf") format("truetype"), url("/font/droidserif-regular-webfont.svg#webfontpB9xBi8Q") format("svg");
        font-weight: normal;
        font-style: normal;
    }
    @font-face {
        font-family: "DroidSerif Bold";
        src: url("/font/droidserif-bold-webfont.eot");
        src: local("DroidSerif Bold"), url("/font/droidserif-bold-webfont.woff") format("woff"), url("/font/droidserif-bold-webfont.ttf") format("truetype"), url("/font/droidserif-bold-webfont.svg#webfontpB9xBi8Q") format("svg");
        font-weight: normal;
        font-style: normal;
    }
    
    
    body {
        font-family: "DroidSerif Regular" , serif;
    }
    h1 {
        font-weight: bold;
        font-family: "DroidSerif Bold";
    }
    

提交回复
热议问题