CSS

@font-face.font-family

@font-face.font-family

CSS属性font-family允许您通过给定一个有先后顺序的,由字体名或者字体族名组成的列表来为选定的元素设置字体。 属性的值用逗号隔开。浏览器会选择列表中第一个该计算机上有安装的字体,或者是通过@font-face指定的可以直接下载的字体。

Related at-rule@font-face
初始值n/a (required)
使用媒体all
计算值as specified
正规顺序the unique non-ambiguous order defined by the formal grammar

语法

/* <string> values */ font-family: "font family"; font-family: 'another font family'; /* <custom-ident> value */ font-family: examplefont;

取值

<family-name>一个字体族的名字。例如"Times" 和 "Helvetica" 都是字体族名。字体族名可以包含空格,但包含空格时应该用引号。

形式语法

<family-name>where <family-name> = <string> | <custom-ident>+

实例

@font-face { font-family: examplefont; src: url('examplefont.ttf' }

规范

SpecificationStatusComment
CSS Fonts Module Level 3The definition of 'font-family' in that specification.Candidate RecommendationInitial definition

浏览器兼容性

FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
Basic support412.03.5 (1.9.1)6.09.03.1

FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MiniOpera MobileSafari Mobile
Basic support2.21.0 (1.9.1)10.0No support12.03.1