CSSFontFaceRule
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
CSSFontFaceRule 接口表示 @font-face at 规则。
实例属性
继承其祖先 CSSRule 的属性。
CSSFontFaceRule.style只读-
返回一个
CSSStyleDeclaration。
实例方法
继承其祖先 CSSRule 的方法。
示例
此示例使用 @font-face 页面上的示例 CSS。返回的第一个 CSSRule 将是一个 CSSFontFaceRule。
css
@font-face {
font-family: MyHelvetica;
src:
local("Helvetica Neue Bold"), local("HelveticaNeue-Bold"),
url(MgOpenModernaBold.ttf);
font-weight: bold;
}
js
const myRules = document.styleSheets[0].cssRules;
console.log(myRules[0]); // CSSFontFaceRule
规范
| Specification |
|---|
| CSS Fonts Module Level 4> # om-fontface> |
浏览器兼容性
Loading…