@font-face not working

后端 未结 11 1446
说谎
说谎 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:04

    I'm also facing this type of problem. After trying all solutions I got final solution on this problem. Reasons for this type of problem is per-defined global fonts. Use !important keyword for each line in @font-face is the solution for this problem.

    Full description and example for Solution of this problem is here :- http://answerdone.blogspot.com/2017/06/font-face-not-working-solution.html

    0 讨论(0)
  • 2020-12-13 19:05

    Double period (..) means you go up one folder and then look for the folder behind the slash. For example:

    If your index.html is in the folder html/files and the fonts are in html/fonts, the .. is fine (because you have to go back one folder to go to /fonts). Is your index.html in html and your fonts in html/fonts, then you should use only one period.

    Another problem could be that your browser might not support .eot font-files.

    Without seeing more of your code (and maybe a link to a live version of your website), I can't really help you further.

    Edit: Forget the .eot part, I missed the .ttf file in your css.

    Try the following:

    @font-face { 
    font-family: Gotham;
    src: url(../fonts/gothammedium.eot);
    src: url(../fonts/Gotham-Medium.ttf); 
    }
    
    0 讨论(0)
  • 2020-12-13 19:07

    Not sure exactly what your problem is, but try the following:

    1. Do the font files exist?
    2. Do you need quotes around the URLs?
    3. Are you using a CSS3-enabled browser?

    Check here for examples, if they don't work for you then you have another problem

    Edit:

    You have a bunch of repeated declarations in your source, does this work?

    @font-face { font-family: Gotham; src: url('../fonts/gothammedium.eot'); }
    
    a { font-family:Gotham,Verdana,Arial; }
    
    0 讨论(0)
  • 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!

    0 讨论(0)
  • 2020-12-13 19:08

    You need to put the font file name / path in quotes.
    Eg.

    url("../fonts/Gotham-Medium.ttf")
    

    or

    url('../fonts/Gotham-Medium.ttf')
    

    and not

    url(../fonts/Gotham-Medium.ttf)
    

    Also @FONT-FACE only works with some font files. :o(

    All the sites where you can download fonts, never say which fonts work and which ones don't.

    0 讨论(0)
  • 2020-12-13 19:08

    try to put below html in head tag.It worked for me.

     <title>ABC</title>
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 
     <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    0 讨论(0)
提交回复
热议问题