css @font-face not working with firefox

2019-03-06 15:21发布

问题:

The following code works in Google Chrome beta as well as IE 7 but not in firefox.

@font-face {
font-family: 'open_sans_semiboldregular';
src: url('../fonts/opensans-semibold-webfont.eot');
src: url('../fonts/opensans-semibold-webfont.eot?#iefix') format('embedded-opentype'),
     url('../fonts/opensans-semibold-webfont.woff') format('woff'),
     url('../fonts/opensans-semibold-webfont.ttf') format('truetype'),
     url('../fonts/opensans-semibold-webfont.svg#open_sans_semiboldregular') format('svg');

}

回答1:

try this

@font-face
{
    font-family: 'SegoeUI';
    src: url('Fonts/segoeui.eot');
    src: url('Fonts/segoeui.eot?#iefix') format('embedded-opentype'), url('fonts/segoeui.ttf') format('truetype');
}

@font-face
{
    font-family: 'SegoeLight';
    src: url('Fonts/segoeuil.eot');
    src: url('Fonts/segoeuil.eot?#iefix') format('embedded-opentype'), url('fonts/segoeuil.ttf') format('truetype');
}


回答2:

For an easier solution, try using Google Web Fonts: http://www.google.com/webfonts

The specific header code to include Open Sans semi-bold is:

<link href='http://fonts.googleapis.com/css?family=Open+Sans:600' rel='stylesheet' type='text/css'>

And then in the CSS it would be:

body {font-family: 'Open Sans', sans-serif;}

This will not only address cross-browser compatibility, but speed up your page load due to being hosted on Google's servers.