CSS Nesting
CSSネスティング
CSSネスティングは、あるスタイルルールの中に別のスタイルルールを書くための組み込み構文です。ブラウザは依然としてセレクターの読み取りやその重要度に関してCSS規則に従います。
もう一つの例
ボタンは `.button` 内に `&:hover`、`&:focus-visible`、および `@media (forced-colors: active)` をネストします。これにより、6つの状態ルールが基本ルールの近くに保持されます。レビューでは、3レベルの子セレクタを拒否します。なぜなら、それらはボタンを特定のページ構造に結び付けてしまうからです。
主な部分
- 01親スタイル規則
- 02ネストされたセレクターまたはアットルール
- 03解決済みセレクター
以下の場合に使用します
状態、バージョン、および同じコンポーネントに属する条件付きアットルールには、1〜2層の浅いレベルを使用します。
以下の場合は使用しないでください
深い子チェーンや正確なDOM構造への隠れた結びつきを避ける。ネイティブのネスティングは常にCSSプリプロセッサのように動作するわけではない。
コードで使用する名前
nested style rules with &, relative selectors, and nested group rules 出荷前に
Check content order, shared design values, component consistency, contrast, zoom, and layout changes by screen size. Verify every theme, language, and state. If there is motion, offer an equal reduced-motion experience.
Outcome:Complete the task with CSSネスティング (CSS Nesting)。 User context:ボタンは `.button` 内に `&:hover`、`&:focus-visible`、および `@media (forced-colors: active)` をネストします。これにより、6つの状態ルールが基本ルールの近くに保持されます。レビューでは、3レベルの子セレクタを拒否します。なぜなら、それらはボタンを特定のページ構造に結び付けてしまうからです。 Design concept to apply:CSSネスティング (CSS Nesting)。 Why it fits:状態、バージョン、および同じコンポーネントに属する条件付きアットルールには、1〜2層の浅いレベルを使用します。 Do not use it when:深い子チェーンや正確なDOM構造への隠れた結びつきを避ける。ネイティブのネスティングは常にCSSプリプロセッサのように動作するわけではない。 Design requirements: Set the content order, shared design values, and reusable components. Define how the layout changes by screen size and state. Keep useful design choices separate from decoration. Inclusion and resilience: Check contrast, zoom, languages, themes, and reduced motion when needed. Do not use color or effects as the only way to show meaning. Acceptance criteria: The design stays clear on phones and desktops, at zoom, in every theme, and in all supported languages. Interactive states stay clear and consistent. Evidence and limits (evidence boundary):きちんとした書類でも、まだドラフトやリリース候補、あるいは最終版かもしれません。ステータスや、ブラウザやプラットフォームの対応状況を確認しましょう。 Unknowns to confirm: Brand limits, amount of content, supported themes and languages, target devices, and design-system rules.
このリクエストを確認する
Review how CSSネスティング (CSS Nesting) is used now. Definition: CSSネスティングは、あるスタイルルールの中に別のスタイルルールを書くための組み込み構文です。ブラウザは依然としてセレクターの読み取りやその重要度に関してCSS規則に従います。 Release checks: Check content order, shared design values, component consistency, contrast, zoom, and layout changes by screen size. Verify every theme, language, and state. If there is motion, offer an equal reduced-motion experience. Before changing code, list the evidence, gaps, severity, and the smallest safe fix.