font-kerning

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2020 年 1 月⁩ 起,所有主流瀏覽器均已支援。

font-kerning CSS 屬性設定是否使用字型中儲存的字偶間距資訊。

試一試

font-kerning: auto;
font-kerning: normal;
font-kerning: none;
<section class="default-example" id="default-example">
  <div class="transition-all" id="example-element">
    “We took Tracy to see ‘THE WATERFALL’ in W. Virginia.”
  </div>
</section>
section {
  font-family: serif;
}

字偶間距 影響字母間的間距。在經過良好調整字偶間距的字型中,此功能透過減少某些字元組合之間的空白,使字元間距更均勻、更易於閱讀。

例如,在下面的圖片中,左側的示例不使用字偶間距,而右側的示例使用字偶間距。

Example of font-kerning

語法

css
font-kerning: auto;
font-kerning: normal;
font-kerning: none;

/* Global values */
font-kerning: inherit;
font-kerning: initial;
font-kerning: revert;
font-kerning: revert-layer;
font-kerning: unset;

auto

瀏覽器決定是否使用字偶間距。例如,某些瀏覽器會在小字型上停用字偶間距,因為應用它可能會損害文字的可讀性。

normal

必須應用字型中儲存的字偶間距資訊。

none

字型中儲存的字偶間距資訊已停用。

正式定義

初始值auto
應用於所有元素和文字。它也適用於 ::first-letter::first-line
繼承性
計算值同指定值
動畫型別離散

正式語法

font-kerning = 
auto |
normal |
none

示例

啟用和停用字偶間距

HTML

html
<div id="kern"></div>
<div id="no-kern"></div>
<textarea id="input">AV T. ij</textarea>

CSS

css
div {
  font-size: 2rem;
  font-family: serif;
}

#no-kern {
  font-kerning: none;
}

#kern {
  font-kerning: normal;
}

JavaScript

js
const input = document.getElementById("input");
const kern = document.getElementById("kern");
const noKern = document.getElementById("no-kern");

input.addEventListener("keyup", () => {
  kern.textContent = input.value; /* Update content */
  noKern.textContent = input.value;
});

kern.textContent = input.value; /* Initialize content */
noKern.textContent = input.value;

規範

規範
CSS 字型模組第 4 級
# font-kerning-prop

瀏覽器相容性

另見