- CSS 教程
- CSS - 首页
- CSS - 路线图
- CSS - 简介
- CSS - 语法
- CSS - 选择器
- CSS - 包含
- CSS - 测量单位
- CSS - 颜色
- CSS - 背景
- CSS - 字体
- CSS - 文本
- CSS - 图片
- CSS - 链接
- CSS - 表格
- CSS - 边框
- CSS - 块级边框
- CSS - 行内边框
- CSS - 外边距
- CSS - 列表
- CSS - 内边距
- CSS - 光标
- CSS - 轮廓
- CSS - 尺寸
- CSS - 滚动条
- CSS - 行内块
- CSS - 下拉菜单
- CSS - 可见性
- CSS - 溢出
- CSS - 清除浮动
- CSS - 浮动
- CSS - 箭头
- CSS - 调整大小
- CSS - 引号
- CSS - 顺序
- CSS - 定位
- CSS - 连字符
- CSS - 悬停
- CSS - 显示
- CSS - 焦点
- CSS - 缩放
- CSS - 位移
- CSS - 高度
- CSS - 连字符字符
- CSS - 宽度
- CSS - 不透明度
- CSS - Z-Index
- CSS - 底部
- CSS - 导航栏
- CSS - 叠加层
- CSS - 表单
- CSS - 对齐
- CSS - 图标
- CSS - 图片库
- CSS - 注释
- CSS - 加载器
- CSS - 属性选择器
- CSS - 组合器
- CSS - 根元素
- CSS - 盒模型
- CSS - 计数器
- CSS - 剪裁
- CSS - 书写模式
- CSS - Unicode-bidi
- CSS - min-content
- CSS - 全部
- CSS - 内嵌
- CSS - 隔离
- CSS - 溢出滚动
- CSS - Justify Items
- CSS - Justify Self
- CSS - 制表符大小
- CSS - 指针事件
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - 最大块级尺寸
- CSS - 最小块级尺寸
- CSS - 混合模式
- CSS - 最大内联尺寸
- CSS - 最小内联尺寸
- CSS - 偏移
- CSS - 强调色
- CSS - 用户选择
- CSS 高级
- CSS - 网格
- CSS - 网格布局
- CSS - Flexbox
- CSS - 可见性
- CSS - 定位
- CSS - 层
- CSS - 伪类
- CSS - 伪元素
- CSS - @规则
- CSS - 文字效果
- CSS - 分页媒体
- CSS - 打印
- CSS - 布局
- CSS - 验证
- CSS - 图片精灵
- CSS - !important
- CSS - 数据类型
- CSS3 教程
- CSS3 - 教程
- CSS - 圆角
- CSS - 边框图片
- CSS - 多重背景
- CSS - 颜色
- CSS - 渐变
- CSS - 盒阴影
- CSS - 盒装饰中断
- CSS - 光标颜色
- CSS - 文本阴影
- CSS - 文本
- CSS - 2D 变换
- CSS - 3D 变换
- CSS - 过渡
- CSS - 动画
- CSS - 多列
- CSS - 盒大小
- CSS - 工具提示
- CSS - 按钮
- CSS - 分页
- CSS - 变量
- CSS - 媒体查询
- CSS - 函数
- CSS - 数学函数
- CSS - 遮罩
- CSS - 形状
- CSS - 图片样式
- CSS - 特异性
- CSS - 自定义属性
- CSS 响应式
- CSS 响应式 - 简介
- CSS 响应式 - 视口
- CSS 响应式 - 网格视图
- CSS 响应式 - 媒体查询
- CSS 响应式 - 图片
- CSS 响应式 - 视频
- CSS 响应式 - 框架
- CSS 工具
- CSS - 像素到 EM 转换器
- CSS - 颜色选择器和动画
- CSS 资源
- CSS - 有用资源
- CSS - 讨论
CSS - font-synthesis 属性
CSS font-synthesis 属性决定浏览器是否应该合成在指定的字体系列中缺失的粗体、斜体和/或小型大写字体。它是以下属性的简写属性:font-synthesis-weight、font-synthesis-style、font-synthesis-small-caps 和 font-synthesis-position
语法
font-synthesis: none | weight | style | small-caps | position | initial | inherit;
属性值
| 值 | 描述 |
|---|---|
| none | 表示浏览器不能合成任何粗体、斜体或小型大写字体。默认值。 |
| weight | 表示如果需要,浏览器可以合成缺失的粗体字体。 |
| style | 表示如果需要,浏览器可以合成斜体字体。 |
| small-caps | 表示如果需要,浏览器可以合成小型大写字体。 |
| position | 表示如果需要,浏览器可以合成下标和上标字体。 |
| initial | 将属性设置为其初始值。 |
| inherit | 从父元素继承该属性。 |
CSS font-synthesis 属性示例
以下示例解释了使用不同值的 font-synthesis 属性。
使用 none 值的 font-synthesis 属性
为了不让浏览器在指定的字体没有粗体、斜体或小型大写字体时合成它们,我们使用 none 值。这在以下示例中显示。
示例
<!DOCTYPE html>
<html>
<head>
<style>
.example {
margin-bottom: 20px;
padding: 10px;
border: 1px solid #ddd;
}
.no-synthesis {
font-family: "Arial", sans-serif;
font-weight: bold;
font-style: italic;
font-synthesis: none;
}
</style>
</head>
<body>
<h2>
CSS font-synthesis property
</h2>
<h4>
font-synthesis: none
</h4>
<div class="example no-synthesis">
This text is styled with `font-synthesis: none;`.
The browser will not synthesize any styles.
If the Arial font does not have a bold or
italic variant, those styles will not appear.
</div>
</body>
</html>
使用 weight 值的 font-synthesis 属性
为了让浏览器在指定的字体没有粗体字体时合成它,我们使用 weight 值。这在以下示例中显示。
示例
<!DOCTYPE html>
<html>
<head>
<style>
.example {
margin-bottom: 20px;
padding: 10px;
border: 1px solid #ddd;
}
.synthesize-weight {
font-family: "Arial", sans-serif;
font-weight: bold;
font-synthesis: weight;
}
</style>
</head>
<body>
<h2>
CSS font-synthesis property
</h2>
<h4>
font-synthesis: weight
</h4>
<div class="example synthesize-weight">
This text is styled with `font-synthesis: weight;`.
The browser will synthesize a bold version
if Arial does not include it.
</div>
</body>
</html>
使用 style 值的 font-synthesis 属性
为了让浏览器在指定的字体没有斜体字体时合成它,我们使用 style 值。这在以下示例中显示。
示例
<!DOCTYPE html>
<html>
<head>
<style>
.example {
margin-bottom: 20px;
padding: 10px;
border: 1px solid #ddd;
}
.synthesize-style {
font-family: "Arial", sans-serif;
font-style: italic;
font-synthesis: style;
}
</style>
</head>
<body>
<h2>
CSS font-synthesis property
</h2>
<h4>
font-synthesis: style
</h4>
<div class="example synthesize-style">
This text is styled with `font-synthesis: style;`.
The browser will synthesize an italic version
if Arial does not include it.
</div>
</body>
</html>
使用 small-caps 值的 font-synthesis 属性
为了让浏览器在指定的字体没有小型大写字体时合成它,我们使用 small-caps 值。这在以下示例中显示。
示例
<!DOCTYPE html>
<html>
<head>
<style>
.example {
margin-bottom: 20px;
padding: 10px;
border: 1px solid #ddd;
}
.synthesize-small-caps {
font-family: "Arial", sans-serif;
font-variant-caps: small-caps;
font-synthesis: small-caps;
}
</style>
</head>
<body>
<h2>
CSS font-synthesis property
</h2>
<h4>
font-synthesis: style
</h4>
<div class="example synthesize-small-caps">
This has `font-synthesis: small-caps;`. The browser
will synthesize a small-caps version if Arial does
not include it.
</div>
</body>
</html>
使用 position 值的 font-synthesis 属性
为了让浏览器在指定的字体没有下标和上标字体时合成它们,我们使用 position 值。这在以下示例中显示。
示例
<!DOCTYPE html>
<html>
<head>
<style>
.example {
margin-bottom: 20px;
padding: 10px;
border: 1px solid #ddd;
font-family: "Arial", sans-serif;
font-synthesis: position;
}
.synthesize-pos1 {
font-variant-position: sub;
}
.synthesize-pos2 {
font-variant-position: super;
}
</style>
</head>
<body>
<h2>
CSS font-synthesis property
</h2>
<h4>
font-synthesis: position
</h4>
<div class="example synthesize-pos1 synthesize-pos2">
This text has `font-synthesis: position;`. The browser
will synthesize a
<sup>
superscript
</sup> and
<sub>
subscript
</sub>
Arial text if it does not include it.
</div>
</body>
</html>
支持的浏览器
| 属性 | ![]() |
![]() |
![]() |
![]() |
![]() |
|---|---|---|---|---|---|
| font-synthesis | 97 | 97 | 34 | 9 | 83 |
css_properties_reference.htm
广告




