Querying Multiple Font Weights with @font-face
In the situation where multiple font variations are available with varying weight and styles, such as the Klavika font mentioned, it is natural to inquire if it is possible to consolidate these imports into a single @font-face query to avoid repetitive copying.
The answer lies in a specialized form of @font-face that allows you to define weight within the query itself.
For instance, to import the Klavika family with various weights and styles, you can utilize the following:
@font-face { font-family: "Klavika"; src: url("Klavika-Regular.otf") format("truetype") weight:normal; src: url("Klavika-Bold.otf") format("truetype") weight:bold; src: url("Klavika-Regular-Italic.otf") format("truetype") weight:normal style:italic; src: url("Klavika-Bold-Italic.otf") format("truetype") weight:bold style:italic; }
This approach grants the ability to specify font-weight or font-style for any element without the need to explicitly declare the font-family or override previously set font weight and style. For example:
body { font-family:"Klavika", Georgia, serif; } h1 { font-weight:bold; } em { font-style:italic; } strong em { font-weight:bold; font-style:italic; }
The above is the detailed content of Can I Import Multiple Font Weights with a Single @font-face Query?. For more information, please follow other related articles on the PHP Chinese website!