@font-face not working

后端 未结 11 1489
说谎
说谎 2020-12-13 18:28

Don\'t know why but font is not displaying.Please help.

CSS(in css folder): style.css:

@font-face { 
 font-family: Gotham;
 src: url(../fonts/goth         


        
11条回答
  •  死守一世寂寞
    2020-12-13 19:08

    I was having this same issue and I thought I'd share my solution as I didn't see anyone address this problem specifically.

    The problem was I wasn't using the correct path. My CSS looked like this:

    @font-face {
    font-family: 'sonhoregular';
    src: url('fonts/vtkssonho-webfont.eot');
    src: url('fonts/vtkssonho-webfont.eot?') format('embedded-opentype'),
         url('fonts/vtkssonho-webfont.woff2') format('woff2'),
         url('fonts/vtkssonho-webfont.woff') format('woff'),
         url('fonts/vtkssonho-webfont.ttf') format('truetype'),
         url('fonts/vtkssonho-webfont.svg#vtks_sonhoregular') format('svg');
    font-weight: normal;
    font-style: normal;
    

    The problem with the path is that I am referring to the font from my CSS file, which is in my CSS folder. I needed to come up a level first, then into the fonts folder. This is what it looks like now, and works great.

    @font-face {
    font-family: 'sonhoregular';
    src: url('../fonts/vtkssonho-webfont.eot');
    src: url('../fonts/vtkssonho-webfont.eot?') format('embedded-opentype'),
         url('../fonts/vtkssonho-webfont.woff2') format('woff2'),
         url('../fonts/vtkssonho-webfont.woff') format('woff'),
         url('../fonts/vtkssonho-webfont.ttf') format('truetype'),
         url('../fonts/vtkssonho-webfont.svg#vtks_sonhoregular') format('svg');
    font-weight: normal;
    font-style: normal;
    

    I hope this helps someone out!

提交回复
热议问题