CSS - font-palette 屬性



CSS 提供的font-palette 屬性允許您指定字型中包含的各種調色盤之一。

可能的值

  • normal:設定預設顏色調色盤或字形著色。渲染索引為 0 的調色盤。

  • light:設定與“light”匹配的第一個調色盤。如果找不到匹配項,則其行為類似於normal

  • dark:設定與“dark”匹配的第一個調色盤。如果找不到匹配項,則其行為類似於normal

  • <調色盤識別符號>:允許使用@font-palette-values @規則指定您自己的調色盤。

應用於

所有 HTML 元素。

DOM 語法

object.style.fontPalette = "normal | <palette identifier>";

CSS font-palette - 基本示例

這是一個示例

<html>
<head>
<style>
    @import url(https://fonts.googleapis.com/css2?family=Bungee+Spice);
    @font-palette-values --bungee-more-spicy {
        font-family: "Bungee Spice";
        override-colors:
        0 Orange,
        1 Yellow;
    }
    h2 {
        font-family: "Bungee Spice";
    }
    h2.more-spicy {
        font-palette: --bungee-more-spicy;
    }
</style>
</head>
<body>
    <h2>Font face</h2>
    <h2 class="more-spicy">Hot & burning</h2>
</body>
</html>
廣告
© . All rights reserved.