我的字体没有加载CSS

时间:2017-06-15 10:48:31

标签: css

我正在尝试从我的本地文件夹中调用我的本地字体,这些字体名为fonts,但这些字体不是在css中加载而在下面是  

@font-face {
    font-weight: normal;
    font-style: normal;
    font-family: 'ProximaNova';
    src: url('fonts/ProximaNova-Regular.eot');
    src: url('fonts/ProximaNova-Regular.woff2') format('woff2'),
       url('fonts/ProximaNova-Regular.woff') format('woff'),
      url('fonts/ProximaNova-Regular.ttf')  format('truetype'),
       url('fonts/ProximaNova-Regular.svg') format('svg');
}

先谢谢

1 个答案:

答案 0 :(得分:1)

检查您的路径,最佳做法是始终使用相对路径

    • 的index.html
    • add_ons
      • style_sheets
        • 的style.css
      • 来源
        • 字体
          • ProximaNova-Regular.woff2
          • ProximaNova-Regular.eot
          • ProximaNova-Regular.woff
          • ProximaNova-Regular.ttf
          • ProximaNova-Regular.svg

应该是,

@font-face {
        font-weight: normal;
        font-style: normal;
        font-family: 'ProximaNova';
        src: url('../sources/fonts/ProximaNova-Regular.eot');
        src: url('../sources/fonts/ProximaNova-Regular.woff2') format('woff2'),
           url('../sources/fonts/ProximaNova-Regular.woff') format('woff'),
          url('../sources/fonts/ProximaNova-Regular.ttf')  format('truetype'),
           url('../sources/fonts/ProximaNova-Regular.svg') format('svg');
    }