大网数据广告活动
Web 标准与前端开发

`base-palette` CSS at-rule descriptor

· 52CE 我爱测

The **`base-palette`** CSS descriptor is used to specify the name or index of a pre-defined palette to be used for creating a new palette. If the specified `base-palette` does not exist, then the palette defined at index 0 will be used.

The base-palette CSS descriptor is used to specify the name or index of a pre-defined palette to be used for creating a new palette. If the specified base-palette does not exist, then the palette defined at index 0 will be used.

Syntax

@font-palette-values --one {
  base-palette: 1;
}

The base-palette descriptor is specified using a zero-based index of the font-maker created palettes.

Values

  • <index>
    • : Specifies the index of the pre-defined palette to use.

Formal definition

Formal syntax

Examples

Changing the default palette in a font

Using the Rocher Color Font, this example shows two instances of switching the default palette in the font to an alternate palette created by the font-maker.

HTML

<h2>default base-palette</h2>
<h2 class="two">base-palette at index 2</h2>
<h2 class="five">base-palette at index 5</h2>

CSS

@font-face {
  font-family: "Rocher";
  src: url("[path-to-font]/RocherColorGX.woff2") format("woff2");
}

h2 {
  font-family: "Rocher", fantasy;
}

@font-palette-values --two {
  font-family: "Rocher";
  base-palette: 2;
}

@font-palette-values --five {
  font-family: "Rocher";
  base-palette: 5;
}

.two {
  font-palette: --two;
}

.five {
  font-palette: --five;
}

Result

Example showing 3 different base-palettes of Rocher color font

Specifications

Browser compatibility

See also

  • @font-palette-values
  • @font-palette-values/font-family descriptor
  • @font-palette-values/override-colors descriptor
  • font-palette property
  • CSSFontPaletteValuesRule.basePalette

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。