实例属性
继承自其祖先 CSSRule 的属性。
CSSPositionTryRule.name只读-
表示
@position-tryat-rule 的<dashed-ident>指定的位置尝试选项的名称。 CSSPositionTryRule.style只读-
一个
CSSPositionTryDescriptors对象,它代表@position-tryat-rule 主体中设置的声明。
实例方法
没有特定的方法;继承自其祖先 CSSRule 的方法。
示例
CSS 包含一个 @position-try at-rule,其名称为 --custom-left,并带有三个描述符。
css
@position-try --custom-left {
position-area: left;
width: 20%;
max-width: 200px;
margin-right: 10px;
}
js
const myRules = document.styleSheets[0].cssRules;
const tryOption = myRules[0]; // a CSSPositionTryRule
console.log(tryOption); // "[object CSSPositionTryRule]"
console.log(tryOption.name); // "--custom-left"
console.log(tryOption.style); // "[object CSSPositionTryDescriptors]"
console.log(tryOption.style.maxWidth); // "200px"
规范
| 规范 |
|---|
| CSS 锚点定位 # csspositiontryrule |
浏览器兼容性
加载中…