Perché Chrome non visualizza il mio @font-face?

0

Domanda

Io sono il caricamento di un Hello World file html in Chrome 95, con una dichiarata @font-face caricato da Google font. Il font è caricato correttamente, che posso verificare nella scheda di Rete, ma per qualche motivo il div è come Tempi di rendering.

Che cosa sto facendo di sbagliato?

<html>
<div style='font-family:OpenSans-Regular;'>
    Hello World!
</div>
</html>
<style>
    @font-face {
      font-family: OpenSans-Regular;
      font-style: normal;
      font-weight: 400;
      font-stretch: 100%;
      font-display: swap;
      src: url(https://fonts.gstatic.com/s/opensans/v27/memvYaGs126MiZpBA-UvWbX2vVnXBbObj2OVTSKmu0SC55K5gw.woff2) format('woff2');
    }
</style>
css font-face google-chrome html
2021-11-23 02:28:37
1

Migliore risposta

1

Da Google font documento, si dovrebbe utilizzare <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Font+Name"> invece di scrivere direttamente a loro.

Il <style> elemento sono nel posto sbagliato, non ci sono <body> elemento HTML.

<html>
    <head>
        <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans">

        <style>
            * {
                font-family: "Open Sans";
            }
        </style>
    </head>
    <body>
        <div style='font-family:Open Sans'>
            Hello World!
        </div>
    </body>
</html>
2021-11-23 03:23:17

In altre lingue

Questa pagina è in altre lingue

Русский
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................