font-variant-alternates屬性是CSS3屬性之一,通常用於啟用各種字體相關的函數,這些函數可以改善頁麵上文本的外觀。 font-variant-alternates屬性用於專門選擇備用字形。
對於任何給定的字符,除了該字符的默認字形之外,字體還可以提供各種其他字形。通過font-variant-alternates屬性,可以選擇給定情況所需的特定字形。
用法:
font-variant-alternates:normal | historical-forms | stylistic() | styleset() | character-variant() | swash() | ornaments() | annotation();
屬性值:
- Keyword Values:它使用關鍵字值“normal”和“historical-forms”。
- Functional Notation Values:它采用的函數標記值為“swash”,“ornaments”,“annotation”,“styleset”,“stylistic”。
- Global Values:它采用全局值“initial”,“inherit”和“unset”。
例:
HTML
<!DOCTYPE html>
<html>
<head>
<style>
@font-feature-values "Leitura Display Swashes" {
@swash {
fancy:1;
}
}
p {
font-size:5rem;
}
.variantAlternates {
font-family:Leitura Display Swashes;
font-variant-alternates:swash(fancy);
color:green;
}
</style>
</head>
<body>
<p class="variantAlternates">GeeksforGeeks</p>
</body>
</html>
輸出:

以上代碼的輸出。
支持的瀏覽器:僅Firefox瀏覽器支持此屬性。
相關用法
- CSS transition-property用法及代碼示例
- CSS table-layout用法及代碼示例
- CSS text-align用法及代碼示例
- CSS border-top-width用法及代碼示例
- CSS isolation屬性用法及代碼示例
- CSS border-inline-start-style屬性用法及代碼示例
- CSS column-rule-width用法及代碼示例
- CSS word-spacing用法及代碼示例
- CSS animation-delay用法及代碼示例
- CSS margin-top用法及代碼示例
- CSS grid屬性用法及代碼示例
- CSS font-size-adjust用法及代碼示例
- CSS visibility屬性用法及代碼示例
- CSS grid-template-columns用法及代碼示例
- CSS height屬性用法及代碼示例
- CSS transform-origin用法及代碼示例
- CSS animation-name用法及代碼示例
- CSS flex-wrap用法及代碼示例
- CSS align-content用法及代碼示例
- CSS page-break-before屬性用法及代碼示例
- CSS empty-cells用法及代碼示例
注:本文由純淨天空篩選整理自cyber_psych0大神的英文原創作品 CSS font-variant-alternates Property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。