試一試
font-optical-sizing: auto;
font-optical-sizing: none;
<section id="default-example">
<div id="example-element">
<h2>Chapter 3</h2>
<p>
On this particular Thursday, something was moving quietly through the
ionosphere many miles above the surface of the planet; several somethings
in fact, several dozen huge yellow chunky slablike somethings, huge as
office blocks, silent as birds.
</p>
</div>
</section>
@font-face {
src: url("/shared-assets/fonts/variable-fonts/AmstelvarAlpha-VF.ttf");
font-family: "Amstelvar";
font-style: normal;
}
#example-element {
font-family: "Amstelvar", serif;
text-align: left;
}
#example-element h2 {
font-size: 36px;
}
#example-element p {
font-size: 12px;
}
語法
css
/* keyword values */
font-optical-sizing: none;
font-optical-sizing: auto; /* default */
/* Global values */
font-optical-sizing: inherit;
font-optical-sizing: initial;
font-optical-sizing: revert;
font-optical-sizing: revert-layer;
font-optical-sizing: unset;
值
描述
對於具有光學尺寸可變軸的字型,預設啟用光學尺寸調整。光學尺寸可變軸在 font-variation-settings 中以 opsz 表示。
使用光學尺寸調整時,小文字通常會以更粗的筆畫和更大的襯線呈現,而大文字通常會呈現得更精緻,粗細筆畫之間的對比度更高。
正式定義
| 初始值 | auto |
|---|---|
| 應用於 | 所有元素和文字。它也適用於 ::first-letter 和 ::first-line。 |
| 繼承性 | 是 |
| 計算值 | 同指定值 |
| 動畫型別 | 離散 |
正式語法
font-optical-sizing =
auto |
none
示例
停用光學尺寸調整
html
<p class="optical-sizing">
This paragraph is optically sized. This is the default across browsers.
</p>
<p class="no-optical-sizing">
This paragraph is not optically sized. You should see a difference in
supporting browsers.
</p>
css
@font-face {
src: url("AmstelvarAlpha-VF.ttf");
font-family: "Amstelvar";
font-style: normal;
}
p {
font-size: 36px;
font-family: "Amstelvar", serif;
}
.no-optical-sizing {
font-optical-sizing: none;
}
注意: 上述引用的字型(包含光學尺寸調整功能並免費許可)非常適合測試。您可以在 GitHub 上下載它。
規範
| 規範 |
|---|
| CSS 字型模組第 4 級 # font-optical-sizing-def |
瀏覽器相容性
載入中…