このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

CSSPositionTryRule

Baseline 2026
最近利用可能

January 2026以降、この機能は最新のバージョンの端末およびブラウザーで動作します。古い端末やブラウザーでは動作しないことがあります。

CSSPositionTryRule インターフェイスは、@position-try アットルールを表すオブジェクトを示します。

CSSRule CSSPositionTryRule

インスタンスプロパティ

祖先である CSSRule から継承したプロパティがあります。

CSSPositionTryRule.name 読取専用

@position-try アットルールの <dashed-ident> で指定された位置試行オプションの名前を表します。

CSSPositionTryRule.style 読取専用

CSSPositionTryDescriptors オブジェクトで、この @position-try アットルールの本体で設定された宣言を表します。

インスタンスメソッド

固有のメソッドはありません。祖先である ancestor CSSRule から継承したメソッドがあります。

この CSS には、@position-try アットルールがあり、これには --custom-left という名前がついており、3 つの記述子があります。

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]; // 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 Anchor Positioning Module Level 1
# csspositiontryrule

ブラウザーの互換性

関連情報