font-size-adjust

基線 2024

最新可用

2024 年 7 月起,此功能可在最新的裝置和瀏覽器版本中使用。此功能可能在較舊的裝置或瀏覽器中無法使用。

font-size-adjust 屬性允許作者為元素指定一個縱橫比值,該值將在替代字型中保留首選字型的 x 高度。

注意:作為表示屬性,font-size-adjust 可以用作 CSS 屬性。有關更多資訊,請參閱 CSS font-size-adjust 屬性。

您可以將此屬性與以下 SVG 元素一起使用

示例

html
<svg
  width="600"
  height="80"
  viewBox="0 0 500 80"
  xmlns="http://www.w3.org/2000/svg">
  <text y="20" font-family="Times, serif" font-size="10px">
    This text uses the Times font (10px), which is hard to read in small sizes.
  </text>
  <text y="40" font-family="Verdana, sans-serif" font-size="10px">
    This text uses the Verdana font (10px), which has relatively large lowercase
    letters.
  </text>
  <text
    y="60"
    font-family="Times, serif"
    font-size="10px"
    font-size-adjust="0.58">
    This is the 10px Times, but now adjusted to the same aspect ratio as the
    Verdana.
  </text>
</svg>

用法說明

預設值 none
none | <number>
可動畫
none

僅根據 font-size 屬性選擇字型大小。

<number>

選擇字型大小,以便其小寫字母(由字型的 x 高度確定)是 font-size 的指定倍數。

指定的數字通常應該是首選 font-family縱橫比(x 高度與字型大小的比率)。這意味著,當首選字型可用時,它在瀏覽器中的顯示大小將相同,無論它們是否支援 font-size-adjust

0 生成高度為零的文字(隱藏文字)。

規範

規範
CSS 字型模組級別 4
# font-size-adjust-prop

瀏覽器相容性

BCD 表格僅在啟用 JavaScript 的瀏覽器中載入。

另請參閱