CSS 中能否引用环境属性,就像引用自定义变量那样?

例如希望能 height: line-height;height: var(line-height);,并自动保持动态映射,不需要 JS 介入?

(补充:我知道自定义变量怎么获取,我是想引用原生属性,就像 JS 中的 getComputedStyle 那样)

最佳答案

你自己不都说出来了嘛。。。不过兼容性稍微可能差点。

:root {
  --global-line-height: 20px;
}
.xx {
  height: var(--global-line-height);
}