CSS 字体 is a module of CSS that defines font-related properties and how font resources are loaded. It lets you define the style of a font, such as its family, size and weight, line height, and the glyph variants to use when multiple are available for a single character.
The following example shows a simple use of basic font properties to style a paragraph of text.
p {
width: 600px;
margin: 0 auto;
font-family: "Helvetica Neue", "Arial", sans-serif;
font-style: italic;
font-weight: 100;
font-variant-ligatures: normal;
font-size: 2rem;
letter-spacing: 1px;
}
<p>Three hundred years ago<br> I thought I might get some sleep<br> I stretched myself out onna antique bed<br> An' my spirit did a midnite creep</p>
The result is as follows:
You can find a number of variable fonts examples at v-fonts.com and axis-praxis.org ; see also our Variable fonts guide for more information and usage information.
font
font-family
font-feature-settings
font-kerning
font-language-override
font-optical-sizing
font-size
font-size-adjust
font-stretch
font-style
font-synthesis
font-variant
font-variant-alternates
font-variant-caps
font-variant-east-asian
font-variant-ligatures
font-variant-numeric
font-variant-position
font-variation-settings
font-weight
line-height
@font-face
font-family
font-feature-settings
font-style
font-variant
font-weight
font-stretch
src
unicode-range
@font-feature-values
In this beginner's learning article we go through all the basic fundamentals of text/font styling in detail, including setting font weight, family and style, font shorthand, text alignment and other effects, and line and letter spacing.
font-feature-settings
. This article provides you with all you need to know about using OpenType font features in CSS.
| 规范 | 状态 | 注释 |
|---|---|---|
| CSS Fonts Module Level 4 | 工作草案 |
添加
font-variation-settings
(and related higher-level properties) and
font-optical-sizing
.
|
| CSS Fonts Module Level 3 | 候选推荐 |
添加
font-feature-settings
(and related higher-level properties)
|
| CSS Level 2 (Revision 1) | 推荐 | |
| CSS Level 1 | 推荐 | 初始定义 |
font
font-family
font-feature-settings
font-kerning
font-language-override
font-optical-sizing
font-size
font-size-adjust
font-stretch
font-style
font-synthesis
font-variant
font-variant-alternates
font-variant-caps
font-variant-east-asian
font-variant-ligatures
font-variant-numeric
font-variant-position
font-variation-settings
font-weight
line-height
line-height-step