2017-02-23 7 views
0

Ich habe eine neue Schriftart heruntergeladen und speichert in ${RootFolder}/font.
In styles.css Datei schrieb ich:CSS @ font-face: Wie man es richtig benutzt?

@font-face { 
    font-family: roboto; 
    url('../fonts/Roboto-Italic.ttf'); 
} 
h1 { 
    font-family: roboto; 
} 

In html Ich schrieb:

<h1> hello </h1> 

Und ich sehe noch nicht, dass Schriftart geändert hat.

Weißt du, was ich falsch gemacht habe?

Antwort

2

Probieren Sie es wie folgt aus:

@font-face { 
    font-family: "roboto"; 
    src: url('fonts/Roboto-Italic.ttf'); 
} 
h1 { 
    font-family: roboto; 
} 
2

Mit google Schriftarten https://fonts.google.com/specimen/Roboto
einfach importieren diese in die CSS. Ersetzen Sie die @ font-face mit:

@import url('https://fonts.googleapis.com/css?family=Roboto:300,400,700'); 

Und verwenden wie font-family: roboto;