html - 字体不适用于所有浏览器

标签 html css cross-browser font-face

我尝试使用 face-font 向我的页面添加几种字体,但不幸的是,即使我按照说明使其与浏览器兼容,它也只能在 Chrome 和 Safari 上运行,我无法弄清楚为什么.我尝试了两种不同的方法。

第一个看起来像这样:

@font-face {
  font-family: 'robotoblack';
  src: url('roboto-black-webfont.eot'); /* per IE 5-8 */
  src: local('☺'), /* direttiva local per IE */
  url('roboto-black-webfont.woff') format('woff'),    /* Firefox 3.6+, Chrome 5.0+, IE 9.0+ */
        url('roboto-black-webfont.ttf') format('truetype'); /* Opera, Safari */
}

@font-face {
  font-family: 'robotomedium_italic';
  src: url('roboto-mediumitalic-webfont.eot'); /* per IE 5-8 */
  src: local('☺'), /* direttiva local per IE */
  url('roboto-mediumitalic-webfont.woff') format('woff'),    /* Firefox 3.6+, Chrome 5.0+, IE 9.0+ */
        url('roboto-mediumitalic-webfont.ttf') format('truetype'); /* Opera, Safari */
}

第二个像这样:

@font-face {
  font-family: 'robotoblack';
  src: url('roboto-black-webfont.eot'); /* IE9 Compat Modes */
  src: url('roboto-black-webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
       url('roboto-black-webfont.woff2') format('woff2'), /* Super Modern Browsers */
       url('roboto-black-webfont.woff') format('woff'), /* Pretty Modern Browsers */
       url('roboto-black-webfont.ttf')  format('truetype'), /* Safari, Android, iOS */
       url('roboto-black-webfont.svg#robotoblack') format('svg'); /* Legacy iOS */
}

@font-face {
  font-family: 'robotomedium_italic';
  src: url('roboto-mediumitalic-webfont.eot'); /* IE9 Compat Modes */
  src: url('roboto-mediumitalic-webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
       url('roboto-mediumitalic-webfont.woff2') format('woff2'), /* Super Modern Browsers */
       url('roboto-mediumitalic-webfont.woff') format('woff'), /* Pretty Modern Browsers */
       url('roboto-mediumitalic-webfont.ttf')  format('truetype'), /* Safari, Android, iOS */
       url('roboto-mediumitalic-webfont.svg#robotomedium_italic') format('svg'); /* Legacy iOS */
}

你能告诉我这两种方法中哪一种是最好的吗?有什么让它适用于所有浏览器的建议吗?

如果您想查看示例,可以在此处找到:

enter link description here

希望对您有所帮助!提前致谢

干杯

恩里科

最佳答案

我看到了答案,你错误地调用了字体系列。确保使用 @font-face 字体系列声明。在这种情况下,请使用“robotoblack”而不是“roboto-black”。并在调用字体时在 css 中使用引号。

我还建议先调用@font-face,然后在css 中调用那些font-families。

关于html - 字体不适用于所有浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37776453/

相关文章:

html - 当我在我的电脑上运行此搜索可折叠树代码时,它不起作用?

javascript - 管理 Javascript 文件中的事件传播

css - 自定义字体未在 IE 中显示

css - Flexbox css 获取高度 100%

css - 如何用背景颜色显示 md-toast

径向渐变的CSS浏览器检测?

javascript - 在所有浏览器的 HTML 页面中嵌入 .wav 文件(无控件)

html - 按属性条件删除某些div

javascript - 如何防止CSS缩放动画的水平滚动

iphone - 如果我正在设计 iPhone 应用程序,我应该使用固定定位吗?