CSSFontFaceRule: style-Eigenschaft

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2016.

Die schreibgeschützte style-Eigenschaft der CSSFontFaceRule-Schnittstelle gibt die Stilinformationen aus der @font-face-At-Regel zurück. Dies erfolgt in Form eines CSSStyleDeclaration-Objekts.

Wert

Beispiele

Dieses Beispiel verwendet das CSS, das als Beispiel auf der Seite @font-face zu finden ist. Die erste zurückgegebene CSSRule ist eine CSSFontFaceRule. Die style-Eigenschaft gibt eine CSSStyleDeclaration zurück, wobei die Eigenschaften fontFamily, fontWeight und src mit den Informationen aus der Regel gefüllt sind.

css
@font-face {
  font-family: MyHelvetica;
  src:
    local("Helvetica Neue Bold"), local("HelveticaNeue-Bold"),
    url(MgOpenModernaBold.ttf);
  font-weight: bold;
}
js
let myRules = document.styleSheets[0].cssRules;
console.log(myRules[0].style); //a CSSStyleDeclaration

Spezifikationen

Specification
CSS Fonts Module Level 4
# dom-cssfontfacerule-style

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
style

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support