CSSFontFaceRule:style 属性
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
接口的只读属性 style
返回 @font-face
At 规则的样式信息。这些信息以 CSSStyleDeclaration
对象的形式提供。
值
示例
以下示例使用了 @font-face
页面中的示例 CSS。返回的第一个 CSSRule
将是一个 CSSFontFaceRule
。style
属性返回一个 CSSStyleDeclaration
,其中包含 fontFamily
、fontWeight
和 src
属性,这些属性包含规则中的信息。
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].style); // CSSStyleDeclaration
规范
Specification |
---|
CSS Fonts Module Level 4> # dom-cssfontfacerule-style> |
浏览器兼容性
Loading…