CSSPositionTryRule: name 属性

可用性有限

此特性不是基线特性,因为它在一些最广泛使用的浏览器中不起作用。

CSSPositionTryRule 接口的只读属性 name 代表了由 @position-try at-rule 的 <dashed-ident> 指定的位置尝试备选项的名称。

字符串。

示例

CSS 包含一个名为 --custom-bottom 且具有三个描述符的 @position-try at-rule。

css
@position-try --custom-bottom {
  top: anchor(bottom);
  min-width: 100px;
  margin-top: 10px;
}
js
const myRules = document.styleSheets[0].cssRules;
const tryOption = myRules[0]; // a CSSPositionTryRule
console.log(tryOption.name); // "--custom-bottom"

规范

规范
CSS 锚点定位
# dom-csspositiontryrule-name

浏览器兼容性

另见