De ce este Chrome nu-mi expun @font-face?

0

Problema

Eu sunt de încărcare un Hello World fișier html în Chrome 95, cu un declarate @font-face încărcat de la Google fonturi. Fontul este corect de încărcare, care pot verifica în tab-ul de Rețea, dar pentru unii motiv, mi div este rendering ca Ori.

Ce fac gresit?

<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

Cel mai bun răspuns

1

De la Google fonturi document, ar trebui să utilizați <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Font+Name"> în loc de a scrie-le în mod direct.

Dvs. <style> elementul se află în locul nepotrivit, nu există <body> element in 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

În alte limbi

Această pagină este în alte limbi

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