font-synthesis-weight
font-synthesis-weight CSS 屬性允許你指定當字型家族中缺少粗體字形時,瀏覽器是否可以合成粗體字形。
通常,使用簡寫屬性 font-synthesis 來控制所有字型合成值會更方便。
語法
css
/* Keyword values */
font-synthesis-weight: auto;
font-synthesis-weight: none;
/* Global values */
font-synthesis-weight: inherit;
font-synthesis-weight: initial;
font-synthesis-weight: revert;
font-synthesis-weight: revert-layer;
font-synthesis-weight: unset;
值
正式定義
| 初始值 | auto |
|---|---|
| 應用於 | 所有元素和文字。它也適用於 ::first-letter 和 ::first-line。 |
| 繼承性 | 是 |
| 計算值 | 同指定值 |
| 動畫型別 | 離散 |
正式語法
font-synthesis-weight =
auto |
none
示例
停用粗體字形合成
此示例展示了在 Montserrat 字型中關閉瀏覽器合成粗體字形。
HTML
html
<p class="english">
This is the default <strong>bold typeface</strong> and
<em>oblique typeface</em>.
</p>
<p class="english no-syn">
The <strong>bold typeface</strong> is turned off here but not the
<em>oblique typeface</em>.
</p>
CSS
css
@import "https://fonts.googleapis.com/css2?family=Montserrat&display=swap";
.english {
font-family: "Montserrat", sans-serif;
}
.no-syn {
font-synthesis-weight: none;
}
結果
規範
| 規範 |
|---|
| CSS 字型模組第 4 級 # font-synthesis-weight |
瀏覽器相容性
載入中…