ホームページ > 記事 > ウェブフロントエンド > 単一の @font-face 宣言で複数のフォント ウェイトをインポートするにはどうすればよいですか?
Querying Multiple Font Weights with a Single @font-face Declaration
Importing multiple font variants with different weights can be tedious when relying on individual @font-face blocks. CSS offers a solution that combines these variants into a single declaration.
Implementing a Single @font-face Query
The key to achieving this is the specific syntax of the @font-face declaration, which accepts a colon-separated list of font weight, font style, and font family properties. Here's an example:
@font-face { font-family: "Klavika"; src: url("Klavika-Bold.otf") weight:bold, url("Klavika-Light.otf") weight:light; }
By specifying the weight, style, and family properties in this manner, multiple font variants can be imported simultaneously.
Example Usage
This method allows for flexible styling with individual font weights:
h1 { font-weight:bold; font-family: Klavika; } p { font-weight:light; font-family: Klavika; }
Additionally, you can leverage the standard @font-face syntax to specify other font properties, such as src and format.
Further Reading
For an exhaustive exploration of this feature, refer to the provided online resource, which offers a more detailed exposition and additional examples.
以上が単一の @font-face 宣言で複数のフォント ウェイトをインポートするにはどうすればよいですか?の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。