font-size-adjust

Baseline 2024
新推出

自 ⁨2024 年 7 月⁩起,此功能可在最新的设备和浏览器版本上使用。此功能可能无法在较旧的设备或浏览器上使用。

font-size-adjust 属性允许作者为元素指定一个纵横比值,该值将保留替代字体中第一个选择字体的 x-height(x 字高度)。

注意: 作为呈现属性,font-size-adjust 还有一个对应的 CSS 属性:font-size-adjust。当两者都指定时,CSS 属性具有更高的优先级。

你可以将此属性与以下 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-height 确定)是 font-size 的指定倍数。

指定的数字通常应该是第一个选择的 font-family纵横比(x-height 与字体大小的比例)。这意味着,如果第一个选择的字体可用,在浏览器中它将显示相同的大小,无论浏览器是否支持 font-size-adjust

0 会导致文本高度为零(隐藏文本)。

规范

规范
CSS 字体模块第 4 级
# font-size-adjust-prop

浏览器兼容性

另见