font-faceコマンド
コマンド @font-face は、
ファイルに保存されたソースを持つ
カスタムフォントを定義することを可能にします。
このフォントはその後、プロパティ font-family
を使用して接続することができます。
構文
@font-face {
フォント名;
フォント検索ソース;
}
例
ローカルコンピューター上からフォントを探してみましょう:
<body>
This is Montserrat SemiBold.
</body>
@font-face {
font-family: "Montserrat SemiBold";
src: local("Montserrat SemiBold");
}
body {
font-family: "Montserrat SemiBold";
}
#elem {
animation: anim 3s infinite;
border: 1px solid black;
width: 50px;
height: 50px;
}
:
例
次に、フォントを検索するためのリモートサーバーのアドレスを指定しましょう:
<body>
This is Bitstream Vera Serif Bold.
</body>
@font-face {
font-family: "Bitstream Vera Serif Bold";
src: url("https://mdn.github.io/css-examples/web-fonts/VeraSeBd.ttf");
}
body {
font-family: "Bitstream Vera Serif Bold", serif;
}
#elem {
animation: anim 3s infinite;
border: 1px solid black;
width: 50px;
height: 50px;
}
: