當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


CSS font-variant-alternates屬性用法及代碼示例

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瀏覽器支持此屬性。

相關用法


注:本文由純淨天空篩選整理自cyber_psych0大神的英文原創作品 CSS font-variant-alternates Property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。