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.ac.cn/css2?family=Montserrat&display=swap";
.english {
font-family: "Montserrat", sans-serif;
}
.no-syn {
font-synthesis-weight: none;
}
结果
规范
| 规范 |
|---|
| CSS 字体模块第 4 级 # font-synthesis-weight |
浏览器兼容性
加载中…